A successful backup operation adds a single backup set to the media set. The backup set is described in terms of the media set to which the backup belongs. If the backup media consists of only one media family, that family contains the entire backup set. If the backup media consists of multiple media families, the backup set is distributed among them. On each medium, the backup set contains a header that describes the backup set.
The following example shows a Transact-SQL statement that creates a media set called MyAdvWorks_MediaSet_1 for the AdventureWorks database using three tape drives as backup devices:
|
BACKUP DATABASE AdventureWorks
TO TAPE = '\\.\tape0', TAPE = '\\.\tape1', TAPE = '\\.\tape2'
WITH
FORMAT,
MEDIANAME = 'MyAdvWorks_MediaSet_1' |
If successful, this backup operation results in a new media set containing a new media header and one backup set spread across three tapes. The following figure illustrates these results:
Typically, after a media set is created, subsequent backup operations, one after another, append their backup sets to the media set. All of the media used by a backup set make up the media set, regardless of the number of media or backup devices involved. Backup sets are sequentially numbered by their position in the media set, allowing you to specify which backup set to restore.
Every backup operation to a media set must write to the same number and type of backup devices. With multiple devices, as with the first backup set, the content of every subsequent backup set is distributed among the backup media on all of the devices. To continue the above example, a second backup operation (a differential backup) appends information to the same media set:
|
BACKUP DATABASE AdventureWorks
TO TAPE = '\\.\tape0', TAPE = '\\.\tape1', TAPE = '\\.\tape2'
WITH
NOINIT,
MEDIANAME = 'AdventureWorksMediaSet1',
DIFFERENTIAL |
Note: |
|---|
|
The NOINIT option is the default, but is included for clarity.
|
If the second backup operation succeeds, it writes a second backup set to the media set, with the following distribution of backup content:
When you are restoring backups, you can use you the FILE option to specify which backups you want to use. The following example shows the use of FILE = backup_set_file_number clauses when restoring a full database backup of the AdventureWorks database followed by a differential database backup on the same media set. The media set uses three backup tapes, which are on tape drives \\.\tape0, tape1, and tape2.
|
RESTORE DATABASE AdventureWorks FROM TAPE = '\\.\tape0', TAPE = '\\.\tape1', TAPE = '\\.\tape2'
WITH
MEDIANAME = 'AdventureWorksMediaSet1',
FILE=1,
NORECOVERY;
RESTORE DATABASE AdventureWorksFROM TAPE = '\\.\tape0', TAPE = '\\.\tape1', TAPE = '\\.\tape2'
WITH
MEDIANAME = 'AdventureWorksMediaSet1',
FILE=2,
RECOVERY;
GO |
For information about the history tables that store information about media sets and their media families and backup sets, see Viewing Information About Backups.
The number of backup media in a media set depends on several factors:
-
Number of backup devices
-
Type of backup devices
-
Number of backup sets
To view the backup sets on a particular backup device