Full Database Backup (Transact-SQL)
A. Backing up to a disk device
The following example backs up the complete AdventureWorks2008R2 database to disk, by using FORMAT to create a new media set.
USE AdventureWorks2008R2; GO BACKUP DATABASE AdventureWorks2008R2 TO DISK = 'Z:\SQLServerBackups\AdventureWorks2008R2.Bak' WITH FORMAT, MEDIANAME = 'Z_SQLServerBackups', NAME = 'Full Backup of AdventureWorks2008R2'; GO
B. Backing up to a tape device
The following example backs up the complete AdventureWorks2008R2 database to tape, appending the backup to the previous backups.
USE AdventureWorks2008R2; GO BACKUP DATABASE AdventureWorks2008R2 TO TAPE = '\\.\Tape0' WITH NOINIT, NAME = 'Full Backup of AdventureWorks2008R2'; GO
C. Backing up to a logical tape device
The following example creates a logical backup device for a tape drive. The example then backs up the complete AdventureWorks2008R2 database to that device.
-- Create a logical backup device, -- AdventureWorks2008R2_Bak_Tape, for tape device \\.\tape0. USE master; GO EXEC sp_addumpdevice 'tape', 'AdventureWorks2008R2_Bak_Tape', '\\.\tape0'; USE AdventureWorks2008R2; GO BACKUP DATABASE AdventureWorks2008R2 TO AdventureWorks2008R2_Bak_Tape WITH FORMAT, MEDIANAME = 'AdventureWorks2008R2_Bak_Tape', MEDIADESCRIPTION = '\\.\tape0', NAME = 'Full Backup of AdventureWorks2008R2'; GO