560
Part V: Enterprise Data Management
Without all the options and frills, the most basic BACKUP command is as follows:
BACKUP DATABASE Databasename
TO DISK = 'file location'
WITH
NAME = 'backup name';
The following command backs up the AdventureWorks2012 database to a disk fi le and
names the backup AdventureWorks2012Backup:
BACKUP DATABASE AdventureWorks2012
TO DISK = 'e:\AdventureWorks2012Backup.bak'
WITH
NAME = 'AdventureWorks2012Backup';
Result:
Processed 17944 pages for database 'AdventureWorks2012', file
'AdventureWorks2012_Data' on file 1.
Processed 2 pages for database 'AdventureWorks2012', file
'AdventureWorks2012_Log' on file 1.
BACKUP DATABASE successfully processed 17946 pages in 7.954 seconds
(17.625 MB/sec).
In SQL Server 2012, the new Always On feature enables you to perform backups against availability replicas in the
availability group as well. For more information on this, see Chapter 27, “Database Mirroring.”
The backup command has a few important options that deserve to be mentioned fi rst:
■ (^) Backing up to a network share: In the TO DISK option, you can use a network
share as a target. Although this is an option, you must ensure that the SQL Server
service account has proper rights on the target fi le share; otherwise you get an
access denied error.
TO DISK = ' \FILESERVER\SQLbackups\AdventureWorks2012Backup.bak'
■ (^) Tape (Backup To:): To backup to tape instead of disk, use the TO TAPE option and
specify the tape-drive location:
TO TAPE = '\.\TAPE0'
Avoid using the Tape option because this feature will be removed in the future release of SQL Server.
■ Differential: Causes the backup command to perform a differential backup
instead of a full database backup. The following command performs a differential
backup:
c21.indd 560c21.indd 560 7/31/2012 9:22:48 AM7/31/2012 9:22:48 AM
http://www.it-ebooks.info