How to create a database backup (Transact-SQL)
To create a database backup
- Execute the BACKUP DATABASE statement to create the database backup, specifying:
- The name of the database to back up.
- The backup device where the database backup will be written.
- The name of the database to back up.
- Optionally, specify:
- The INIT clause to overwrite the backup media, and write the backup as the first file on the backup media. If no existing media header exists, one is automatically written.
- The SKIP and INIT clauses to overwrite the backup media even if there are either backups on the backup media that have not yet expired, or the media name does not match the name on the backup media.
- The FORMAT clause when using media for the first time to completely initialize the backup media and rewrite any existing media header.
The INIT clause is not required if the FORMAT clause is specified.
- The INIT clause to overwrite the backup media, and write the backup as the first file on the backup media. If no existing media header exists, one is automatically written.
Important Use extreme caution when using the FORMAT or INIT clauses of the BACKUP statement, as this will destroy any backups previously stored on the backup media.
Examples
This example backs up the entire MyNwind database to tape:
USE MyNwind
GO
BACKUP DATABASE MyNwind
TO TAPE = '\\.\Tape0'
WITH FORMAT,
NAME = 'Full Backup of MyNwind'
GO
See Also
Backing Up the master Database