SQL Server Storage Engine

Can you mix-n-match backup devices?

I was asked this question yesterday and didn't know the answer so thought it would be good for a quick post. Can you use devices from your main and mirrored backup media sets together to perform a restore?

The code below creates a single-device backup and then examines it.

BACKUP DATABASE AdventureWorks

TO DISK = N'c:\mediaset1device1.bck'

WITH FORMAT, STATS;

GO

RESTORE HEADERONLY FROM DISK=N'c:\mediaset1device1.bck';

GO

The BackupSize in the output is 172,044,800 bytes and the on-disk size of the file is 164MB. Now let's use two devices and see what happens.

BACKUP DATABASE AdventureWorks

TO DISK=N'c:\mediaset1device1.bck', DISK=N'c:\mediaset1device2.bck'

MIRROR TO DISK=N'c:\mediaset2device1.bck', DISK=N'c:\mediaset2device2.bck'

WITH FORMAT, STATS;

GO

RESTORE HEADERONLY FROM DISK=N'c:\mediaset1device1.bck';

GO

The BackupSize is now 344,113,152 bytes (roughly double what it was previously because we've mirrored the whole backup) and the on-disk size of each file is 82MB (half of what it was for a single-device). This proves that the backup has been split over the two devices. Now let's try to mix devices from the two backup media sets and see if it's possible:

RESTORE DATABASE AdventureWorks

FROM DISK=N'c:\mediaset1device1.bck', DISK=N'c:\mediaset2device2.bck'

WITH REPLACE, STATS;

GO

And it works fine - excellent! That's the whole point of having mirrored backups.

The second part of the question was about whether backup device types can differ between media sets in the same backup. The answer to this is no - as documented in Books Online. All the backup devices involved in a single backup, regardless of whether they're part of a mirror media set or not, must be of the same type and have similar characteristics.

Next up - can it hurt to have thousands of filegroups?

Published Sunday, April 22, 2007 5:15 PM by Paul Randal - MSFT

Comments

 

Quanvu said:

Congratulation Paul & Kimberly. and may the "force" be with you two for the rest of the journey until SQL2200 and beyond :-) Thanks for sharing with us and you bet that I will follow you on your new blog until the day I win a big jackpot! :-)  SANH

August 2, 2007 11:09 AM
Anonymous comments are disabled

About Paul Randal - MSFT

Paul started in the industry in 1994 working for DEC on the VMS file system and check/repair tools. In 1999 he moved to Microsoft to work on SQL Server, specifically on DBCC. For SQL Server 2000, he concentrated on index fragmentation (writing DBCC INDEXDEFRAG and DBCC SHOWCONTIG) plus various algorithms in DBCC CHECKDB. During SQL Server 2005 development Paul was the lead developer/manager of one the core dev teams in the Storage Engine, responsible for data access and storage (DBCC, allocation, indexes & heaps, pages/records, text/LOB storage, snapshot isolation, etc). He also spent several years rewriting DBCC CHECKDB and repair. For SQL Server 2008, Paul managed the Program Management team for the core Storage Engine to become more focused on customer/partner engagement and feature set definition. In 2007, after 8.5 years on the SQL Server team, Paul left Microsoft to join his wife, Kimberly Tripp, running SQLskills.com and pursuing his passion for presenting and consulting. Paul regularly presents at conferences and user groups around the world on high-availability, disaster recovery and Storage Engine internals. His popular blog is at http://www.sqlskills.com/blogs/paul/.

© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Microsoft
Page view tracker