Home
%3CLINGO-SUB%20id%3D%22lingo-sub-370339%22%20slang%3D%22en-US%22%3EBackup%20compression%20behavior%20when%20appending%20backups%20to%20an%20existing%20Media%20Set%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-370339%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSTRONG%3E%20First%20published%20on%20MSDN%20on%20Aug%2009%2C%202010%20%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EThere%20will%20be%20an%20upcoming%20Knowledge%20base%20article%20detailing%20this%20out%20as%20well%3C%2FP%3E%0A%3CP%3EWhen%20you%20append%20a%20compressed%20backup%20to%20an%20existing%20Media%2C%20it%20inherits%20the%20compression%20setting%20from%20the%20Media%20set.%26nbsp%3B%20If%20you%20rely%20on%20the%20%E2%80%98backup%20compression%E2%80%99%26nbsp%3B%20sp_configure%20setting%20and%20are%20appending%20to%20existing%20media%20sets%20you%20may%20end%20up%20with%20a%20backup%20in%20a%20different%20compression%20state%20than%20expected%3C%2FP%3E%0A%3CP%3EThis%20is%20true%20only%20under%20the%20following%20circumstances%3C%2FP%3E%0A%3CP%3E%C2%B7%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20You%20Append%20the%20backup%20to%20an%20existing%20media%20set%3C%2FP%3E%0A%3CP%3E%C2%B7%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20You%20rely%20on%20the%20sp_configure%20%E2%80%98backup%20compression%E2%80%99%20option%20and%20do%20not%20specify%20the%20backup%20statement%20level%20%E2%80%9CWITH%20COMPRESSION%E2%80%9D%20option%3C%2FP%3E%0A%3CP%3EBackup%20Compression%20on%20SQL%20Server%20does%20have%20the%20restrictions%20listed%20below%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22http%3A%2F%2Fmsdn.microsoft.com%2Fen-us%2Flibrary%2Fbb964719(SQL.100).aspx%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%20http%3A%2F%2Fmsdn.microsoft.com%2Fen-us%2Flibrary%2Fbb964719(SQL.100).aspx%20%3C%2FA%3E%3C%2FP%3E%0A%3CP%3EOne%20of%20the%20main%20restrictions%20is%20that%20Compressed%20and%20uncompressed%20backups%20cannot%20co-exist%20in%20a%20media%20set.%20This%20article%20tries%20to%20supplement%20this%20information%20specifically%20with%20regards%20to%20the%20backup%20compression%20option%20of%20sp_configure%20and%20it%E2%80%99s%20behavior%20in%20some%20edge%20cases.%3C%2FP%3E%0A%3CP%3EWhen%20we%20create%20a%20new%20media%20set%2C%20we%20do%20encode%20whether%20it%20is%20for%20a%20compressed%20backup%26nbsp%3B%20in%20the%20media%20header.%20Backups%20taken%20to%20an%20existing%20media%20set%20can%20co-exist%20only%20if%20the%20compression%20setting%20is%20the%20same%20as%20of%20the%20media%20set.%20There%20is%20a%20difference%20in%20behavior%20when%20we%20backup%20based%20on%20whether%20we%20use%20the%20default%20backup%20compression%20setting%20in%20sp_configure%20or%20the%20%E2%80%9CWITH%20compression%E2%80%9D%20%26nbsp%3Bor%20the%20%E2%80%9CWITH%20no_compression%E2%80%9D%20option%20of%20the%20backup%20statement%20when%20appending%20to%20a%20Media%20set.%20%26nbsp%3B%26nbsp%3BWhen%20we%20use%20the%20default%20compression%20setting%20at%20the%20server%20and%20append%20to%20an%20existing%20media%20set%2C%20the%20backup%20will%20never%20fail%20due%20to%20a%20mismatch%20in%20compression%20settings%2C%20it%20works%20but%20inherits%26nbsp%3B%20the%20setting%20in%20the%20header%20of%20the%20media%20set.%20However%20if%20you%20specify%20the%20%E2%80%9CWith%20Compression%E2%80%9D%20%26nbsp%3Bor%20the%20%E2%80%9CWith%20No_Compression%E2%80%9D%20option%20of%20the%20backup%20statement%2C%20an%20error%20will%20be%20raised%20if%20there%20is%20a%20mismatch%20between%20the%20backup%20stored%20in%20the%20media%20set%20and%20the%20current%20backup%20being%20taken%20in%20terms%20of%20the%20compression%20setting.%3C%2FP%3E%0A%3CP%3EThe%20following%20is%20a%20table%20that%20tries%20to%20encapsulate%20the%20backup%20behavior%20when%20compression%20is%20at%20play.%3C%2FP%3E%0A%3CTABLE%3E%0A%3CTBODY%3E%0A%3CTR%3E%0A%20%3CTD%20rowspan%3D%222%22%20backgrond-color%3D%22grey%22%3E%26nbsp%3B%3C%2FTD%3E%0A%20%3CTD%20rowspan%3D%222%22%20backgrond-color%3D%22grey%22%3E%3CSTRONG%3ENew%20MediaSet%3C%2FSTRONG%3E%3C%2FTD%3E%0A%20%3CTD%20colspan%3D%222%22%20backgrond-color%3D%22grey%22%3E%3CSTRONG%3E%20Append%20to%20Media%20Set%20%3C%2FSTRONG%3E%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%20%3CTD%20backgrond-color%3D%22silver%22%3E%3CSTRONG%3E%20Existing%20Media%20Set%20has%20Compressed%20Backup%20%3C%2FSTRONG%3E%3C%2FTD%3E%0A%20%3CTD%20backgrond-color%3D%22silver%22%3E%3CSTRONG%3E%20Exsting%20Media%20Set%20has%20uncompressed%20backup%20%3C%2FSTRONG%3E%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%20%3CTD%20backgrond-color%3D%22grey%22%3E%3CSTRONG%3E%20Backup%26nbsp%3B%20statement%20level%20%E2%80%9CWITH%20COMPRESSION%E2%80%9D%20%26nbsp%3Bclause%20%3C%2FSTRONG%3E%3C%2FTD%3E%0A%20%3CTD%3E%3CP%3ESuccess%3C%2FP%3EBackup%20compressed%3CP%3E%3C%2FP%3E%0A%20%3C%2FTD%3E%0A%20%3CTD%3E%3CP%3ESuccess%3C%2FP%3E%0A%20%3C%2FTD%3E%0A%20%3CTD%3E%3CP%3EErrors%3C%2FP%3E%0A%20%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%20%3CTD%20backgrond-color%3D%22grey%22%3E%3CSTRONG%3E%20Backup%26nbsp%3B%20statement%20level%20%E2%80%9CWITH%20NO_COMPRESSION%E2%80%9D%20%26nbsp%3Bclause%20%3C%2FSTRONG%3E%3C%2FTD%3E%0A%20%3CTD%3E%3CP%3ESuccess%3C%2FP%3E%0A%20%20%3CP%3EBackup%20-%20uncompressed%3C%2FP%3E%0A%20%3C%2FTD%3E%0A%20%3CTD%3E%3CP%3EErrors%3C%2FP%3E%0A%20%3C%2FTD%3E%0A%20%3CTD%3E%3CP%3ESuccess%3C%2FP%3E%0A%20%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%20%3CTD%20backgrond-color%3D%22grey%22%3E%3CSTRONG%3E%20Backup%20statement%20without%20Compression%20clause%20%3C%2FSTRONG%3E%3C%2FTD%3E%0A%20%3CTD%3E%3CP%3ESuccess%3C%2FP%3E%0A%20%20%3CP%3ECompression%20depends%20on%20sp_configure%20%E2%80%98backup%20compression%E2%80%99%20setting%3C%2FP%3E%0A%20%3C%2FTD%3E%0A%20%3CTD%3E%3CP%3ESuccess%3C%2FP%3E%0A%20%20%3CP%3EBackup%20will%20be%20compressed%3C%2FP%3E%0A%20%3C%2FTD%3E%0A%20%3CTD%3E%3CP%3ESuccess%3C%2FP%3E%0A%20%20%3CP%3EBackup%20will%20be%20uncompressed%3C%2FP%3E%0A%20%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3C%2FTBODY%3E%0A%3C%2FTABLE%3E%0A%3CP%3EHere%20is%20a%20sample%20Script%20to%20demonstrate%20that%20behavior.%20The%20Behavior%20is%20the%20same%20whether%20the%20backup%20is%20to%20TAPE%20or%20a%20disk.%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3ENOTE%3A%20%3C%2FSTRONG%3E%20Tape%20is%20not%20natively%20included%20in%20Windows%20Server%202008%20R2.%3C%2FP%3E%0A%3CPRE%3E%0A--%20Note%20compression%20value%2C%20by%20default%20it%20should%20be%200%0Asp_configure%20'backup%20compression'%0A%0A--%20Initial%20Backup%20completes%20successfully%0ABACKUP%20DATABASE%20test%20TO%20DISK%20%3D%20N'E%3A%5Ctestbackup.bak'%0AWITH%20FORMAT%0A%20%2CINIT%0A%20%2CNAME%20%3D%20N'testbackup-Full%20Database%20Backup'%0A%20%2CSKIP%0A%20%2CNOUNLOAD%0A%20%2CSTATS%20%3D%2010%0AGO%0A%0A--%20Check%20the%20backup%20and%20the%20header%2C%20not%20the%20Compressed%20value%0ARESTORE%20headeronly%0AFROM%20DISK%20%3D%20N'E%3A%5Ctestbackup.bak'%0A%3C%2FPRE%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20671px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F89352i29E566F6D60FA75B%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CPRE%3E%0A--%20Now%20backup%20using%20%22with%20compression%22%20and%20it%20will%20fail%20as%20backups%20(%20compressed%20and%20non%20compressed%20cannot%20be%20mixed%20within%20the%20same%20media%20set%20)%0ABACKUP%20DATABASE%20test%20TO%20DISK%20%3D%20N'E%3A%5Ctestbackup.bak'%0AWITH%20NAME%20%3D%20N'testbackup-Full%20Database%20Backup'%0A%20%2CSKIP%0A%20%2CNOREWIND%0A%20%2CNOUNLOAD%0A%20%2CCOMPRESSION%0A%20%2CSTATS%20%3D%2010%0AGO%0A%3C%2FPRE%3E%0A%3CPRE%3E%0A%3CFONT%20color%3D%22red%22%3E%0A%20Msg%203098%2C%20Level%2016%2C%20State%202%2C%20Line%201%0A%0A%20The%20backup%20cannot%20be%20performed%20because%20'COMPRESSION'%20was%20requested%20after%20the%20media%20was%20formatted%20with%20an%20incompatible%20structure.%20To%20append%20to%20this%20media%20set%2C%20either%20omit%20'COMPRESSION'%20or%20specify%20'NO_COMPRESSION'.%20Alternatively%2C%20you%20can%20create%20a%20new%20media%20set%20by%20using%20WITH%20FORMAT%20in%20your%20BACKUP%20statement.%20If%20you%20use%20WITH%20FORMAT%20on%20an%20existing%20media%20set%2C%20all%20its%20backup%20sets%20will%20be%20overwritten.%0A%0A%20Msg%203013%2C%20Level%2016%2C%20State%201%2C%20Line%201%0A%0A%20BACKUP%20DATABASE%20is%20terminating%20abnormally.%20%0A%3C%2FFONT%3E%0A%3C%2FPRE%3E%0A%0A%3CPRE%3E%0A--%20Turn%20on%20default%20backup%20Compression%20at%20the%20server%20level%0Asp_configure%20'backup%20compression'%2C1%0AGO%0A%0ARECONFIGURE%0AGO%0A%0A--%20The%20sp_configure%20%E2%80%98default%20compression%E2%80%99%20as%20this%20point%20is%20set%20to%201.%0A--%20Given%20that%20you%20may%20expect%20the%20backup%20to%20be%20compressed%20and%20it%20will%20be%20if%20it%20--%20is%20a%20new%20media%20set%0A--%20However%20if%20you%20backup%20and%20append%20to%20the%20same%20media%20set%2C%20the%20backup%20works%20and%20does%20not%20fail%0ABACKUP%20DATABASE%20test%20TO%20DISK%20%3D%20N'E%3A%5Ctestbackup.bak'%0AWITH%20NAME%20%3D%20N'testbackup-Full%20Database%20Backup'%0A%20%2CSKIP%0A%20%2CNOREWIND%0A%20%2CNOUNLOAD%0A%20%2CSTATS%20%3D%2010%0AGO%0A%3C%2FPRE%3E%0A%0A%3CPRE%3E%0AProcessed%202%20pages%20for%20database%20'test'%2C%20file%20'test_log'%20on%20file%202.%0A%0ABACKUP%20DATABASE%20successfully%20processed%20162%20pages%20in%206.211%20seconds%20(0.203%20MB%2Fsec).%20%0A%3C%2FPRE%3E%0A%0A%0A%0A%3CPRE%3E%0A--%20Check%20the%20backup%20and%20meadia%20set%20header.You%20will%20see%20that%20though%20Server%20default%20is%20set%20to%20compressed%2C%20the%20backup%20given%20that%20it%20is%20appended%20to%20an%20existing%20media%20set%20inherits%20the%20compression%20setting%20of%20the%20media%20set%20itself%0A--%20You%20may%20have%20expected%20this%20to%20fail%20failed%20with%20the%20same%20error%20as%20when%20specifying%20the%20WITH%20COMPRESSION%20clause%20in%20the%20backup%20statement%20given%20that%20compressed%20and%20non%20compressed%20backups%20cannot%20co-exist%20in%20the%20media%20set.%0ARESTORE%20headeronly%0AFROM%20DISK%20%3D%20N'E%3A%5Ctestbackup.bak'%0A%3C%2FPRE%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20583px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F89353iFF1B0F6E5A760A12%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%0A%3CPRE%3E%0A--%20If%20you%20create%20a%20new%20media%20set%20using%20the%20FORMAT%20option%2C%20then%20the%20current%20compression%20setting%20is%20inherited%0A--%20Create%20a%20new%20media%20set%20using%20FORMAT%20Or%20by%20specifying%20a%20new%20file%0ABACKUP%20DATABASE%20test%20TO%20DISK%20%3D%20N'E%3A%5Ctestbackup.bak'%0AWITH%20FORMAT%0A%20%2CINIT%0A%20%2CNAME%20%3D%20N'testbackup-Full%20Database%20Backup'%0A%20%2CSKIP%0A%20%2CNOUNLOAD%0A%20%2CSTATS%20%3D%2010%0AGO%0A%0A--%20Check%20the%20backup%20and%20meadia%20set%20header%0ARESTORE%20headeronly%0AFROM%20DISK%20%3D%20N'E%3A%5Ctestbackup.bak'%0A%3C%2FPRE%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20647px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F89354i554C535338423D2F%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CPRE%3E%0A--%20If%20you%20use%20the%20with%20INIT%2C%20%20the%20backup%20sets%20are%20overwritten%20but%20the%20media%20header%20is%20not%0A--%20Toggle%20the%20backup%20compression%20setting%20back%20to%200%0Asp_configure%20'backup%20compression'%2C0%0AGO%0A%0ARECONFIGURE%0AGO%0A%0A--%20backup%20to%20the%20same%20media%20set%20with%20INIT%0ABACKUP%20DATABASE%20test%20TO%20DISK%20%3D%20N'E%3A%5Ctestbackup.bak'%0AWITH%20INIT%0A%20%2CNAME%20%3D%20N'testbackup-Full%20Database%20Backup'%0A%20%2CSKIP%0A%20%2CNOUNLOAD%0A%20%2CSTATS%20%3D%2010%0AGO%0A%0A--%20Check%20the%20backup%20and%20meadia%20set%20header%0A--%20Note%20that%20even%20though%20we%20changed%20backup%20compression%20to%200%2C%20the%20old%20media%20header%20is%20preserved%20which%20has%20it%20as%201%2C%20and%20the%20backup%20goes%20as%20compressed%0ARESTORE%20headeronly%0AFROM%20DISK%20%3D%20N'E%3A%5Ctestbackup.bak'%0A%3C%2FPRE%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20776px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F89355i7ACBD1DF447435B8%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%20Another%20limitation%20is%20that%20Compressed%20Backups%20cannot%20Co-exist%20with%20NT%20backups%20%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CPRE%3E%0A--%20Take%20an%20A%20backup%20to%20TAPE%20from%20either%20NT%20backup%20(%20Windows%202003%20)%20or%20some%20other%20utility%20such%20that%20there%20exists%20a%20backup%20on%20the%20tape%20and%20the%20backup%20is%20taken%20outside%20of%20SQL%20Server%20(%20not%20a%20SQL%20Backup)%0A--%20You%20can%20verify%20the%20backup%20Header%20now%2C%20see%20it%20is%20not%20a%20SQL%20backup%20And%20also%20the%20Backup%20Name%20indicates%20that%20as%20well.%0ARESTORE%20headeronly%0AFROM%20DISK%20%3D%20N'E%3A%5Ctestbackup.bak'%0A%3C%2FPRE%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20772px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F89356iAB2A05A1DBE901AD%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CPRE%3E%0A--%20Take%20a%20SQL%20backup%20to%20the%20same%20media%20set%20with%20INIT%20and%20compression%20and%20you%20get%20the%20error%20message%0ABACKUP%20DATABASE%20test%20TO%20TAPE%20%3D%20N'%5C%5C.%5CTape0'%0AWITH%20INIT%0A%20%2CCOMPRESSION%0A%20%2CNAME%20%3D%20N'testbackup-Full%20Database%20Backup'%0A%20%2CSKIP%0A%20%2CNOUNLOAD%0A%20%2CSTATS%20%3D%2010%0AGO%0A%3C%2FPRE%3E%0A%3CPRE%3E%3CFONT%20color%3D%22red%22%3E%0AMsg%203098%2C%20Level%2016%2C%20State%202%2C%20Line%201%0A%0AThe%20backup%20cannot%20be%20performed%20because%20'COMPRESSION'%20was%20requested%20after%20the%20media%20was%20formatted%20with%20an%20incompatible%20structure.%20To%20append%20to%20this%20media%20set%2C%20either%20omit%20'COMPRESSION'%20or%20specify%20'NO_COMPRESSION'.%20Alternatively%2C%20you%20can%20create%20a%20new%20media%20set%20by%20using%20WITH%20FORMAT%20in%20your%20BACKUP%20statement.%20If%20you%20use%20WITH%20FORMAT%20on%20an%20existing%20media%20set%2C%20all%20its%20backup%20sets%20will%20be%20overwritten.%0A%0AMsg%203013%2C%20Level%2016%2C%20State%201%2C%20Line%201%0A%0ABACKUP%20DATABASE%20is%20terminating%20abnormally.%3C%2FFONT%3E%0A%3C%2FPRE%3E%0A%0A%3CPRE%3E%0A--Take%20a%20SQL%20backup%20to%20the%20same%20media%20set%20without%20initializing%20and%20NO%20compression%20and%20the%20backups%20(%20NT%20and%20non-compressed%20backup)%20can%20co-exist%0ABACKUP%20DATABASE%20test%20TO%20TAPE%20%3D%20N'%5C%5C.%5CTape0'%0AWITH%20NAME%20%3D%20N'testbackup-Full%20Database%20Backup'%0A%20%2CSKIP%0A%20%2CNOUNLOAD%0A%20%2CSTATS%20%3D%2010%0AGO%0A%0A--%20can%20verify%20the%20backup%20Header%20now%2Csee%20the%20SQL%20and%20the%20NT%20backup%0ARESTORE%20headeronly%0AFROM%20TAPE%20%3D%20N'%5C%5C.%5CTape0'%0A%3C%2FPRE%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20794px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F89357i05340C0D89AB3773%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CPRE%3E%0A--%20Forcing%20a%20Compressed%20backup%20on%20a%20tape%20with%20an%20NT%20backup%20results%20in%20the%20error%20below%0ABACKUP%20DATABASE%20test%20TO%20TAPE%20%3D%20N'%5C%5C.%5CTape0'%0AWITH%20compression%0A%20%2CNAME%20%3D%20N'testbackup1%20Full%20Database%20Backup'%0A%20%2CSKIP%0A%20%2CNOUNLOAD%0A%20%2CSTATS%20%3D%2010%0AGO%0A%3C%2FPRE%3E%0A%3CPRE%3E%3CFONT%20color%3D%22red%22%3E%0AMsg%203098%2C%20Level%2016%2C%20State%202%2C%20Line%201%0A%0AThe%20backup%20cannot%20be%20performed%20because%20'COMPRESSION'%20was%20requested%20after%20the%20media%20was%20formatted%20with%20an%20incompatible%20structure.%20To%20append%20to%20this%20media%20set%2C%20either%20omit%20'COMPRESSION'%20or%20specify%20'NO_COMPRESSION'.%20Alternatively%2C%20you%20can%20create%20a%20new%20media%20set%20by%20using%20WITH%20FORMAT%20in%20your%20BACKUP%20statement.%20If%20you%20use%20WITH%20FORMAT%20on%20an%20existing%20media%20set%2C%20all%20its%20backup%20sets%20will%20be%20overwritten.%0A%0AMsg%203013%2C%20Level%2016%2C%20State%201%2C%20Line%201%0A%0ABACKUP%20DATABASE%20is%20terminating%20abnormally.%3C%2FFONT%3E%0A%3C%2FPRE%3E%0A%0A%3CP%3E%3CSTRONG%3E%20-Denzil%20Ribeiro%20%3C%2FSTRONG%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-370339%22%20slang%3D%22en-US%22%3E%3CP%3EFirst%20published%20on%20MSDN%20on%20Aug%2009%2C%202010%20%26nbsp%3BThere%20will%20be%20an%20upcoming%20Knowledge%20base%20article%20detailing%20this%20out%20as%20well%20%26nbsp%3BWhen%20you%20append%20a%20compressed%20backup%20to%20an%20existing%20Media%2C%20it%20inherits%20the%20compression%20setting%20from%20the%20Media%20set.%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-370339%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3Edatabase%20engine%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EDisaster%20Recovery%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Occasional Visitor

First published on MSDN on Aug 09, 2010

There will be an upcoming Knowledge base article detailing this out as well

When you append a compressed backup to an existing Media, it inherits the compression setting from the Media set.  If you rely on the ‘backup compression’  sp_configure setting and are appending to existing media sets you may end up with a backup in a different compression state than expected

This is true only under the following circumstances

·        You Append the backup to an existing media set

·        You rely on the sp_configure ‘backup compression’ option and do not specify the backup statement level “WITH COMPRESSION” option

Backup Compression on SQL Server does have the restrictions listed below

http://msdn.microsoft.com/en-us/library/bb964719(SQL.100).aspx

One of the main restrictions is that Compressed and uncompressed backups cannot co-exist in a media set. This article tries to supplement this information specifically with regards to the backup compression option of sp_configure and it’s behavior in some edge cases.

When we create a new media set, we do encode whether it is for a compressed backup  in the media header. Backups taken to an existing media set can co-exist only if the compression setting is the same as of the media set. There is a difference in behavior when we backup based on whether we use the default backup compression setting in sp_configure or the “WITH compression”  or the “WITH no_compression” option of the backup statement when appending to a Media set.   When we use the default compression setting at the server and append to an existing media set, the backup will never fail due to a mismatch in compression settings, it works but inherits  the setting in the header of the media set. However if you specify the “With Compression”  or the “With No_Compression” option of the backup statement, an error will be raised if there is a mismatch between the backup stored in the media set and the current backup being taken in terms of the compression setting.

The following is a table that tries to encapsulate the backup behavior when compression is at play.

  New MediaSet Append to Media Set
Existing Media Set has Compressed Backup Exsting Media Set has uncompressed backup
Backup  statement level “WITH COMPRESSION”  clause

Success

Backup compressed

Success

Errors

Backup  statement level “WITH NO_COMPRESSION”  clause

Success

Backup - uncompressed

Errors

Success

Backup statement without Compression clause

Success

Compression depends on sp_configure ‘backup compression’ setting

Success

Backup will be compressed

Success

Backup will be uncompressed

Here is a sample Script to demonstrate that behavior. The Behavior is the same whether the backup is to TAPE or a disk.

NOTE: Tape is not natively included in Windows Server 2008 R2.

-- Note compression value, by default it should be 0
sp_configure 'backup compression'

-- Initial Backup completes successfully
BACKUP DATABASE test TO DISK = N'E:\testbackup.bak'
WITH FORMAT
	,INIT
	,NAME = N'testbackup-Full Database Backup'
	,SKIP
	,NOUNLOAD
	,STATS = 10
GO

-- Check the backup and the header, not the Compressed value
RESTORE headeronly
FROM DISK = N'E:\testbackup.bak'

-- Now backup using "with compression" and it will fail as backups ( compressed and non compressed cannot be mixed within the same media set )
BACKUP DATABASE test TO DISK = N'E:\testbackup.bak'
WITH NAME = N'testbackup-Full Database Backup'
	,SKIP
	,NOREWIND
	,NOUNLOAD
	,COMPRESSION
	,STATS = 10
GO

 Msg 3098, Level 16, State 2, Line 1

 The backup cannot be performed because 'COMPRESSION' was requested after the media was formatted with an incompatible structure. To append to this media set, either omit 'COMPRESSION' or specify 'NO_COMPRESSION'. Alternatively, you can create a new media set by using WITH FORMAT in your BACKUP statement. If you use WITH FORMAT on an existing media set, all its backup sets will be overwritten.

 Msg 3013, Level 16, State 1, Line 1

 BACKUP DATABASE is terminating abnormally. 

-- Turn on default backup Compression at the server level
sp_configure 'backup compression',1
GO

RECONFIGURE
GO

-- The sp_configure ‘default compression’ as this point is set to 1.
-- Given that you may expect the backup to be compressed and it will be if it -- is a new media set
-- However if you backup and append to the same media set, the backup works and does not fail
BACKUP DATABASE test TO DISK = N'E:\testbackup.bak'
WITH NAME = N'testbackup-Full Database Backup'
	,SKIP
	,NOREWIND
	,NOUNLOAD
	,STATS = 10
GO
Processed 2 pages for database 'test', file 'test_log' on file 2.

BACKUP DATABASE successfully processed 162 pages in 6.211 seconds (0.203 MB/sec). 
-- Check the backup and meadia set header.You will see that though Server default is set to compressed, the backup given that it is appended to an existing media set inherits the compression setting of the media set itself
-- You may have expected this to fail failed with the same error as when specifying the WITH COMPRESSION clause in the backup statement given that compressed and non compressed backups cannot co-exist in the media set.
RESTORE headeronly
FROM DISK = N'E:\testbackup.bak'

-- If you create a new media set using the FORMAT option, then the current compression setting is inherited
-- Create a new media set using FORMAT Or by specifying a new file
BACKUP DATABASE test TO DISK = N'E:\testbackup.bak'
WITH FORMAT
	,INIT
	,NAME = N'testbackup-Full Database Backup'
	,SKIP
	,NOUNLOAD
	,STATS = 10
GO

-- Check the backup and meadia set header
RESTORE headeronly
FROM DISK = N'E:\testbackup.bak'

-- If you use the with INIT,  the backup sets are overwritten but the media header is not
-- Toggle the backup compression setting back to 0
sp_configure 'backup compression',0
GO

RECONFIGURE
GO

-- backup to the same media set with INIT
BACKUP DATABASE test TO DISK = N'E:\testbackup.bak'
WITH INIT
	,NAME = N'testbackup-Full Database Backup'
	,SKIP
	,NOUNLOAD
	,STATS = 10
GO

-- Check the backup and meadia set header
-- Note that even though we changed backup compression to 0, the old media header is preserved which has it as 1, and the backup goes as compressed
RESTORE headeronly
FROM DISK = N'E:\testbackup.bak'

Another limitation is that Compressed Backups cannot Co-exist with NT backups

-- Take an A backup to TAPE from either NT backup ( Windows 2003 ) or some other utility such that there exists a backup on the tape and the backup is taken outside of SQL Server ( not a SQL Backup)
-- You can verify the backup Header now, see it is not a SQL backup And also the Backup Name indicates that as well.
RESTORE headeronly
FROM DISK = N'E:\testbackup.bak'

-- Take a SQL backup to the same media set with INIT and compression and you get the error message
BACKUP DATABASE test TO TAPE = N'\\.\Tape0'
WITH INIT
	,COMPRESSION
	,NAME = N'testbackup-Full Database Backup'
	,SKIP
	,NOUNLOAD
	,STATS = 10
GO

Msg 3098, Level 16, State 2, Line 1

The backup cannot be performed because 'COMPRESSION' was requested after the media was formatted with an incompatible structure. To append to this media set, either omit 'COMPRESSION' or specify 'NO_COMPRESSION'. Alternatively, you can create a new media set by using WITH FORMAT in your BACKUP statement. If you use WITH FORMAT on an existing media set, all its backup sets will be overwritten.

Msg 3013, Level 16, State 1, Line 1

BACKUP DATABASE is terminating abnormally.
--Take a SQL backup to the same media set without initializing and NO compression and the backups ( NT and non-compressed backup) can co-exist
BACKUP DATABASE test TO TAPE = N'\\.\Tape0'
WITH NAME = N'testbackup-Full Database Backup'
	,SKIP
	,NOUNLOAD
	,STATS = 10
GO

-- can verify the backup Header now,see the SQL and the NT backup
RESTORE headeronly
FROM TAPE = N'\\.\Tape0'

-- Forcing a Compressed backup on a tape with an NT backup results in the error below
BACKUP DATABASE test TO TAPE = N'\\.\Tape0'
WITH compression
	,NAME = N'testbackup1 Full Database Backup'
	,SKIP
	,NOUNLOAD
	,STATS = 10
GO

Msg 3098, Level 16, State 2, Line 1

The backup cannot be performed because 'COMPRESSION' was requested after the media was formatted with an incompatible structure. To append to this media set, either omit 'COMPRESSION' or specify 'NO_COMPRESSION'. Alternatively, you can create a new media set by using WITH FORMAT in your BACKUP statement. If you use WITH FORMAT on an existing media set, all its backup sets will be overwritten.

Msg 3013, Level 16, State 1, Line 1

BACKUP DATABASE is terminating abnormally.

-Denzil Ribeiro