备份和还原复制的数据库Back Up and Restore Replicated Databases

适用对象: yesSQL ServeryesAzure SQL 数据库(仅限托管实例)noAzure SQL 数据仓库no并行数据仓库APPLIES TO: yesSQL Server yesAzure SQL Database (Managed Instance only) noAzure SQL Data Warehouse noParallel Data Warehouse

对于复制的数据库,需要特别注意与备份和还原数据有关的信息。Replicated databases require special attention with regards to backing up and restoring data. 本主题介绍了适用于各种复制类型的备份和还原策略,并提供了其详细信息的链接。This topic provides introductory information and links to further information on backup and restore strategies for each type of replication.

复制支持将复制的数据库还原到从中创建备份的同一服务器和数据库。Replication supports restoring replicated databases to the same server and database from which the backup was created. 如果将复制数据库的备份还原到其他服务器或数据库,则无法保留复制设置。If you restore a backup of a replicated database to another server or database, replication settings cannot be preserved. 在这种情况下,您必须在还原备份后重新创建所有发布和订阅。In this case, you must recreate all publications and subscriptions after backups are restored.

备注

如果正在使用日志传送,则可以将复制数据库还原到备用服务器。It is possible to restore a replicated database to a standby server if log shipping is being used. 有关详细信息,请参阅日志传送和复制 (SQL Server)For more information, see Log Shipping and Replication (SQL Server).

应定期备份复制数据库及其关联系统数据库。Replicated databases and their associated system databases should be backed up regularly. 备份下列数据库:Back up the following databases:

  • 发布服务器上的发布数据库The publication database at the Publisher

  • 分发服务器上的分发数据库The distribution database at the Distributor

  • 各个订阅服务器上的订阅数据库The subscription database at each Subscriber

  • 发布服务器、分发服务器和所有订阅服务器上的 mastermsdb 系统数据库。The master and msdb system databases at the Publisher, Distributor and all Subscribers. 当备份这些数据库中的一个数据库或相关的复制数据库时,应同时备份这些数据库。These databases should be backed up at the same time as each other and the relevant replication database. 例如,应在备份发布数据库的同时备份发布服务器上的 mastermsdb 数据库。For example, back up the master and msdb databases at the Publisher at the same time you back up the publication database. 如果还原发布数据库,请确保 mastermsdb 数据库在复制配置和设置方面与发布数据库保持一致。If the publication database is restored, ensure that the master and msdb database are consistent with the publication database in terms of replication configuration and settings.

如果执行定期日志备份,则在日志备份中应捕获所有与复制相关的更改。If you perform regular log backups, any replication-related changes should be captured in the log backups. 如果不执行日志备份,则当与复制相关的设置发生更改时,应执行备份。If you do not perform log backups, a backup should be performed whenever a setting relevant to replication is changed. 有关详细信息,请参阅 Common Actions Requiring an Updated BackupFor more information, see Common Actions Requiring an Updated Backup.

备份和还原策略Backup and Restore Strategies

复制拓扑中每个节点的备份和还原策略都因所用复制类型的不同而有所差异。The strategies for backing up and restoring each node in a replication topology differ according to the type of replication used. 有关每种复制的备份和还原策略的信息,请参阅下列主题:For information on backup and restore strategies for each type of replication, see the following topics:

作为任何恢复策略的一部分,请始终将当前复制设置的脚本保存在安全的位置。As part of any recovery strategy, always keep a current script of your replication settings in a safe location. 在服务器出现故障或需要设置测试环境时,可以通过更改服务器名称引用来修改脚本,并用该脚本帮助重新创建复制设置。In the event of server failure or the need to set up a test environment, you can modify the script by changing server name references, and it can be used to help recreate your replication settings. 除了编写当前复制设置的脚本之外,还应编写启用和禁用复制的脚本。In addition to scripting your current replication settings, you should script the enabling and disabling of replication. 有关编写复制对象脚本的信息,请参阅 Scripting ReplicationFor information about scripting replication objects, see Scripting Replication.

另请参阅See Also

SQL Server 数据库的备份和还原 Back Up and Restore of SQL Server Databases
Best Practices for Replication AdministrationBest Practices for Replication Administration