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 需要在您的 NAS 上运行 HDP 才能备份或恢复您的服务器。
- 下载并安装 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 Backup Explorer 将文件恢复到我的 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在“查看数据库文件路径”部分中获得的文件路径。
- 下图显示了执行命令后的典型输出。

完成后,您的数据库将被恢复并可供使用。
进一步阅读