Reputation: 63
I create backups from a MS SQL Server Instance in a C# program I developed.
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 remembers backups that are created. How do I create a backup that is not recorded and will not affect other backups or the transaction log?
Upvotes: 2
Views: 226
Reputation: 754468
I guess you're looking for a "copy-only backup" - check out the Microsoft Docs on it.
So basically just add a COPY_ONLY
option to your backup command (in the WITH
section):
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};
Upvotes: 1