我在开发的C#程序中从MS SQL Server实例创建备份。
SqlCommand command = new SqlCommand($"BACKUP DATABASE [{base1C.SqlDbName}] TO
DISK = N'{tp}' WITH NOFORMAT, INIT, NAME = N'{archiveFileName}', NOSKIP,
REWIND, NOUNLOAD, STATS = 10, CHECKSUM", connect) {CommandTimeout = 0};
SQL Server会记住创建的备份。如何创建未记录且不会影响其他备份或事务日志的备份?
答案 0 :(得分:1)
我想您正在寻找“仅复制备份”-请查看Microsoft Docs on it。
因此,基本上,只需在备份命令中添加一个COPY_ONLY
选项(在WITH
部分):
SqlCommand command = new SqlCommand($"BACKUP DATABASE [{base1C.SqlDbName}] TO
DISK = N'{tp}' WITH NOFORMAT, INIT, NAME = N'{archiveFileName}', NOSKIP,
REWIND, NOUNLOAD, STATS = 10, CHECKSUM, COPY_ONLY", connect) {CommandTimeout = 0};