概述
Alwayson在添加数据库的过程中如果同步首选项选择的是“完整”,那么就会在主副本上执行copyonly的完整备份和日志备份在辅助副本上执行还原操作,也正是这个操作让我对copyonly有了新的理解。虽然以前也经常使用copyonly执行完整备份,
但是之前对copyonly的理解存在一点误区。接下来详细说明copyonly的操作。
一、备份测试
CREATE DATABASE city;GOCREATE TABLE city.dbo.test(id INT);---执行完整备份BACKUP DATABASE [city] TO DISK = N'D:\backup\city_full_20170613.bak' WITH NOFORMAT, NOINIT, NAME = N'city-完整 数据库 备份', SKIP, NOREWIND, NOUNLOAD, STATS = 10GO--插入1条记录INSERT INTO city.dbo.test VALUES(1);--执行日志备份1BACKUP LOG [city] TO DISK = N'D:\backup\city_log1_20170613.trn' WITH NOFORMAT, NOINIT, NAME = N'city-日志备份1 备份', SKIP, NOREWIND, NOUNLOAD, STATS = 10GOINSERT INTO city.dbo.test VALUES(2);GO--执行完整copy only备份BACKUP DATABASE [city] TO DISK = N'D:\backup\city_full_copyonly_20170613.bak' WITH COPY_ONLY, NOFORMAT, NOINIT, NAME = N'city-完整copyonly 数据库 备份', SKIP, NOREWIND, NOUNLOAD, STATS = 10GOINSERT INTO city.dbo.test VALUES(3);--执行差异备份BACKUP DATABASE [city] TO DISK = N'D:\backup\city_diff_20170613.bak' WITH DIFFERENTIAL , NOFORMAT, NOINIT, NAME = N'city-差异 数据库 备份', SKIP, NOREWIND, NOUNLOAD, STATS =&n