Legal Information |
|
You can back up a database using T-SQL, which offers options that Enterprise Manager doesn't. The syntax for a full backup is as follows:
BACKUP DATABASE { database_name | @database_name_var } TO < backup_device > [ ,...n ]For a definition of each option, see the description in SQL Books Online.
[ WITH
[ BLOCKSIZE = { blocksize | @blocksize_variable } ]
[ [ , ] DESCRIPTION = { 'text' | @text_variable } ]
[ [ , ] DIFFERENTIAL ]
[ [ , ] EXPIREDATE = { date | @date_var }
| RETAINDAYS = { days | @days_var } ]
[ [ , ] PASSWORD = { password | @password_variable } ]
[ [ , ] FORMAT | NOFORMAT ]
[ [ , ] { INIT | NOINIT } ]
[ [ , ] MEDIADESCRIPTION = { 'text' | @text_variable } ]
[ [ , ] MEDIANAME = { media_name | @media_name_variable } ]
[ [ , ] MEDIAPASSWORD = { mediapassword | @mediapassword_variable } ]
[ [ , ] NAME = { backup_set_name | @backup_set_name_var } ]
[ [ , ] { NOSKIP | SKIP } ]
[ [ , ] { NOREWIND | REWIND } ]
[ [ , ] { NOUNLOAD | UNLOAD } ]
[ [ , ] RESTART ]
[ [ , ] STATS [ =percentage ] ]
Figure D shows an example of how the Pubs database can be backed up. By adding NOINIT, the information can be appended to the end of the backup.
By adding Stats to the argument, an output of the percentage of the backup completed can be received.
A differential backup backs up only the data that has changed since the last full backup. These backups are generally smaller than a full backup and can be used frequently since they run much faster.
To perform a differential backup using T-SQL, use the Backup command but add the differential argument, as shown in Figure E.
A transaction-log backup will back up all transactions that occur in the database and purge or clean up the log after the backup completes.
Using a transaction-log backup gives you point-in-time recovery for a database.
Keep in mind that you must be using Full or Bulk-Logged Recovery Models in order to perform transaction-log backups.
To perform a transaction-log backup with T-SQL, use the following syntax:
BACKUP LOG { database_name | @database_name_var }For a detailed definition of each option, please see the description in SQL Books Online. You can perform the transaction-log backup by using the Backup Log command, as shown in Figure F.
{
TO < backup_device > [ ,...n ]
[ WITH
[ BLOCKSIZE = { blocksize | @blocksize_variable } ]
[ [ , ] DESCRIPTION = { 'text' | @text_variable } ]
[ [ ,] EXPIREDATE = { date | @date_var }
| RETAINDAYS = { days | @days_var } ]
[ [ , ] PASSWORD = { password | @password_variable } ]
[ [ , ] FORMAT | NOFORMAT ]
[ [ , ] { INIT | NOINIT } ]
[ [ , ] MEDIADESCRIPTION = { 'text' | @text_variable } ]
[ [ , ] MEDIANAME = { media_name | @media_name_variable } ]
[ [ , ] MEDIAPASSWORD = { mediapassword | @mediapassword_variable } ]
[ [ , ] NAME = { backup_set_name | @backup_set_name_var } ]
[ [ , ] NO_TRUNCATE ]
[ [ , ] { NORECOVERY | STANDBY =undo_file_name } ]
[ [ , ] { NOREWIND | REWIND } ]
[ [ , ] { NOSKIP | SKIP } ]
[ [ , ] { NOUNLOAD | UNLOAD } ]
[ [ , ] RESTART ]
[ [ , ] STATS [ =percentage ] ]
Search Knowledge Base | Feedback |