Applicable Products
- Hyper Data Protector
- NetBak PC Agent
- Microsoft SQL Server
Prerequisites
To back up and restore your Microsoft SQL Server using the methods outlined in this guide, you need to install Hyper Data Protector (HDP) on your NAS or install NetBak PC Agent on your physical server. Ensure that you install the appropriate application before proceeding.
HDP Installation
- Log in to your NAS as an administrator.
- Open App Center.
- Click
, and then enter "Hyper Data Protector". - Click Install.
NetBak PC Agent Installation
Before installing NetBak PC Agent, ensure that you meet the system requirements. For details, see NetBak PC Agent Quick Start Guide.
- Install HDP following the steps above. NetBak PC Agent requires HDP to be running on your NAS to back up or restore your server.
- Download and install NetBak PC Agent.
Details
This section provides step-by-step instructions on how to back up and restore Microsoft SQL Server using HDP and NetBak PC Agent.
Back up Microsoft SQL Server
Choose the backup method based on your Microsoft SQL Server environment.HDP (for Virtual Machines)
- Add the hypervisor hosting the Microsoft SQL Server to the HDP inventory.
- Create a backup job.
- Configure the backup settings.
- Start the backup job.
For detailed instructions, see Using Hyper Data Protector to Back Up Hypervisors to a QNAP NAS.
NetBak PC Agent (for Physical Servers)
- Create a repository to store your backup data on your NAS.
- Create a backup job.
- Configure the backup settings.
- Start the backup job.
For detailed instructions, see NetBak PC Agent Quick Start Guide.
Restore Your Entire Microsoft SQL Server
Depending on your server environment, you can use HDP to restore your virtual machine to a hypervisor or use NetBak PC Agent to restore your physical server with a USB boot drive.
HDP (for Virtual Machines)
- Create a restore job.
- Select the source to restore.
- Configure the restore settings.
- Start the restore process.
For detailed instructions, see Using Hyper Data Protector to Back Up Hypervisors to a QNAP NAS.
NetBak PC Agent (for Physical Servers)
- Create a USB boot drive.
- Insert the USB boot drive into your server.
- Configure the BIOS boot order.
- Follow the Restore Wizard to restore your server.
For detailed instructions, see the NetBak PC Agent Quick Start Guide.
Restore a Microsoft SQL Database
To restore your Microsoft SQL database to a precise point in time using .mdf and .ldf files, follow the steps below.
- View database file paths.
- Open Microsoft SQL Server Management Studio (SSMS).
- Complete the fields in the Connect to Server dialog box if it appears. For instructions, see this tutorial.
If SSMS automatically connects to your desired server, proceed to the next step. Otherwise, go to Object Explorer > Connect > Database Engine to connect manually. - In the Object Explorer pane, expand Databases.
- Right-click the database you want to restore.
- Click Properties.
The Database Properties dialog box appears. - Click Files on the left panel to view file paths.

- Download database files.
- Open Backup Explorer in HDP.
- Select the database version you want to restore.
- Locate and download the
.mdf and .ldf files to the desired restore destination.
For detailed instructions, see How do I restore files to my Windows PC or server with HDP Backup Explorer?.
- Configure file permissions.
- Open Command Prompt as Administrator.
- Run the following command twice, once for the
.mdf file and once for the .ldffile.icacls File_Path /grant MSSQLSERVER:(F)
- First, replace
File_Path with the .mdf file path obtained in the "View database file paths" section. - Then, replace
File_Path with the .ldf file path obtained in the "View database file paths" section.
- Attach the database.
- Run the following command to open the SQL command-line interface.
sqlcmd -S localhost
- Run the following SQL.
USE [master]
GO
CREATE DATABASE [Database_Name] ON
( FILENAME = N'Disk:\Path\File_Name.mdf' ),
( FILENAME = N'Disk:\Path\File_Name.ldf' )
FOR ATTACH
GO
- Replace the following placeholders.
[Database_Name] with your database name.Disk:\Path\File_Name.mdf with the .mdf file path obtained in the "View database file paths" section. Disk:\Path\File_Name.ldf with the .ldf file path obtained in the "View database file paths" section.
- The image below shows the typical output after executing the command.

Once completed, your database will be restored and available for use.
Further Reading
適用產品
- Hyper Data Protector
- NetBak PC Agent
- Microsoft SQL Server
先決條件
要使用本指南中列出的方式備份和還原您的 Microsoft SQL Server,您需要在您的 NAS 上安裝 Hyper Data Protector (HDP) 或在您的實體伺服器上安裝 NetBak PC Agent。請確保在繼續之前安裝適當的應用程式。
HDP 安裝
- 以 系統管理員 身份登入您的 NAS。
- 打開 App Center。
- 點選
,然後輸入 "Hyper Data Protector"。 - 點選安裝。
NetBak PC Agent 安裝
在安裝 NetBak PC Agent 之前,請確保您符合系統要求。詳情請參閱 NetBak PC Agent 快速入門指南。
- 按照上述步驟安裝 HDP。NetBak PC Agent 需要 HDP 在您的 NAS 上運行以備份或還原您的伺服器。
- 下載並安裝 NetBak PC Agent。
詳情
本節提供有關如何使用 HDP 和 NetBak PC Agent 備份和還原 Microsoft SQL Server 的逐步說明。
備份 Microsoft SQL Server
根據您的 Microsoft SQL Server 環境選擇備份方法。HDP(適用於虛擬機器)
- 將託管 Microsoft SQL Server 的虛擬機器管理程式新增到 HDP 清單中。
- 建立備份任務。
- 配置備份設定。
- 開始備份任務。
詳細說明請參閱 使用 Hyper Data Protector 將虛擬機器管理程式備份到 QNAP NAS。
NetBak PC Agent(適用於實體伺服器)
- 建立一個儲存庫以在您的 NAS 上儲存備份資料。
- 建立備份任務。
- 配置備份設定。
- 開始備份任務。
詳細說明請參閱 NetBak PC Agent 快速入門指南。
還原整個 Microsoft SQL Server
根據您的伺服器環境,您可以使用 HDP 將虛擬機器還原到虛擬機器管理程式,或使用 NetBak PC Agent 使用 USB 啟動驅動器還原您的實體伺服器。
HDP(適用於虛擬機器)
- 建立還原任務。
- 選擇要還原的來源。
- 配置還原設定。
- 開始還原過程。
詳細說明請參閱 使用 Hyper Data Protector 將虛擬機器管理程式備份到 QNAP NAS。
NetBak PC Agent(適用於實體伺服器)
- 建立 USB 啟動驅動器。
- 將 USB 啟動驅動器插入您的伺服器。
- 配置 BIOS 啟動順序。
- 按照還原嚮導還原您的伺服器。
詳細說明請參閱 NetBak PC Agent 快速入門指南。
還原 Microsoft SQL 資料庫
要將您的 Microsoft SQL 資料庫還原到精確的時間點,請使用.mdf和.ldf檔案,請按照以下步驟操作。
- 檢視資料庫檔案路徑。
- 開啟 Microsoft SQL Server Management Studio (SSMS)。
- 如果出現 連接到伺服器 對話框,請完成字段。說明請參閱此 教程。
如果 SSMS 自動連接到您想要的伺服器,請進行下一步。否則,請轉到 對象瀏覽器 > 連接 > 資料庫引擎 手動連接。 - 在物件瀏覽器窗格中,展開資料庫。
- 右鍵點選您想要還原的資料庫。
- 點擊 屬性。
出現 資料庫屬性 對話框。 - 點擊左側面板上的 文件 以查看文件路徑。

- 下載資料庫檔案。
- 在 HDP 中打開 備份總管。
- 選擇您想要還原的資料庫版本。
- 定位並下載
.mdf 和 .ldf 文件到所需的還原目的地。
詳細說明請參閱 如何使用 HDP 備份瀏覽器將文件還原到我的 Windows PC 或伺服器?。
- 配置檔案許可權。
- 以 系統管理員 身份打開命令提示符。
- 執行以下命令兩次,一次用於
.mdf檔案,一次用於.ldf檔案。icacls File_Path /grant MSSQLSERVER:(F)
- 首先,替換
File_Path為.mdf在“檢視資料庫檔案路徑”部分中獲得的檔案路徑。 - 然後,替換
File_Path為.ldf在“檢視資料庫檔案路徑”部分中獲得的檔案路徑。
- 附加資料庫。
- 執行以下命令以開啟 SQL 命令列介面。
sqlcmd -S localhost
- 運行以下 SQL。
USE [master]<br>GO<br>CREATE DATABASE [Database_Name] ON<br>( FILENAME = N'Disk:\Path\File_Name.mdf' ),<br>( FILENAME = N'Disk:\Path\File_Name.ldf' )<br>FOR ATTACH<br>GO
- 替換以下佔位符。
[Database_Name]為您的資料庫名稱。Disk:\Path\File_Name.mdf為.mdf在“檢視資料庫檔案路徑”部分中獲得的檔案路徑。Disk:\Path\File_Name.ldf為.ldf在“檢視資料庫檔案路徑”部分中獲得的檔案路徑。
- 下圖顯示了執行命令後的典型輸出。

完成後,您的資料庫將被還原並可供使用。
進一步閱讀