संपादित करें

इसके माध्यम से साझा किया गया


Backup overview (SQL Server)

Applies to: SQL Server

This article introduces the SQL Server backup component. Backing up your SQL Server database is essential for protecting your data. This discussion covers backup types, and backup restrictions. The topic also introduces SQL Server backup devices and backup media.

Terms

  • back up [verb]: Copies the data or log records from a SQL Server database or its transaction log to a backup device, such as a disk, to create a data backup or log backup.

  • backup [noun]: A copy of SQL Server data that can be used to restore and recover the data after a failure. A backup of SQL Server data is created at the level of a database or one or more of its files or filegroups. Table-level backups cannot be created. In addition to data backups, the full recovery model requires creating backups of the transaction log.

  • recovery model: A database property that controls transaction log maintenance on a database. Three recovery models exist: simple, full, and bulk-logged. The recovery model of database determines its backup and restore requirements.

  • restore: A multi-phase process that copies all the data and log pages from a specified SQL Server backup to a specified database, and then rolls forward all the transactions that are logged in the backup by applying logged changes to bring the data forward in time.

Types of backups

  • copy-only backup: A special-use backup that is independent of the regular sequence of SQL Server backups.

  • data backup: A backup of data in a complete database (a database backup), a partial database (a partial backup), or a set of data files or filegroups (a file backup).

  • database backup: A backup of a database. Full database backups represent the whole database at the time the backup finished. Differential database backups contain only changes made to the database since its most recent full database backup.

  • differential backup: A data backup that is based on the latest full backup of a complete or partial database or a set of data files or filegroups (the differential base) and that contains only the data extents that have changed since the differential base.

    A differential partial backup records only the data extents that have changed in the filegroups since the previous partial backup, known as the base for the differential.

  • full backup: A data backup that contains all the data in a specific database or set of filegroups or files, and also enough log to allow for recovering that data.

  • log backup: A backup of transaction logs that includes all log records that were not backed up in a previous log backup (full recovery model).

  • file backup: A backup of one or more database files or filegroups.

  • partial backup: Contains data from only some of the filegroups in a database, including the data in the primary filegroup, every read/write filegroup, and any optionally specified read-only files.

Backup media terms and definitions

  • backup device: A disk or tape device to which SQL Server backups are written and from which they can be restored. SQL Server backups can also be written to Azure Blob Storage, and URL format is used to specify the destination and the name of the backup file.. For more information, see SQL Server Backup and Restore with Microsoft Azure Blob Storage.

  • backup media: One or more tapes or disk files to which one or more backup have been written.

  • backup set: The backup content that is added to a media set by a successful backup operation.

  • media family: Backups created on a single non-mirrored device or a set of mirrored devices in a media set.

  • media set: An ordered collection of backup media, tapes or disk files, to which one or more backup operations have written using a fixed type and number of backup devices.

  • mirrored media set: Multiple copies (mirrors) of a media set.

Backup compression

SQL Server 2008 (10.0.x) Enterprise edition and later versions support compressing backups, and SQL Server 2008 (10.0.x) and later versions can restore a compressed backup. SQL Server 2016 (13.x) Standard edition and later versions support compressing backups, and restoring compressed backups. For more information, see Backup compression (SQL Server).

Backup operations restrictions

Backup can occur while the database is online and being used. However, the following restrictions exist:

Cannot back up offline data

Any backup operation that implicitly or explicitly references data that is offline fails. Some typical examples include the following:

  • You request a full database backup, but one filegroup of the database is offline. Because all filegroups are implicitly included in a full database backup, this operation fails.

    To back up this database, you can use a file backup and specify only the filegroups that are online.

  • You request a partial backup, but a read/write filegroup is offline. Because all read/write filegroups are required for a partial backup, the operation fails.

  • You request a file backup of specific files, but one of the files is not online. The operation fails. To back up the online files, you can omit the offline file from the file list and repeat the operation.

Typically, a log backup succeeds even if one or more data files are unavailable. However, if any file contains bulk-logged changes made under the bulk-logged recovery model, all the files must be online for the backup to succeed.

Concurrency restrictions

SQL Server uses an online backup process to allow for a database backup while the database is still being used. During a backup, most operations are possible; for example, INSERT, UPDATE, or DELETE statements are allowed during a backup operation. However, if you try to start a backup operation while a database file is being created or deleted, the backup operation waits until the create or delete operation is finished or the backup times out.

Operations that cannot run during a database backup or transaction log backup include the following:

  • File-management operations such as the ALTER DATABASE statement with either the ADD FILE or REMOVE FILE options.

  • Shrink database or shrink file operations. This includes auto-shrink operations.

  • If you try to create or delete a database file while a backup operation is in progress, the create or delete operation fails.

If a backup operation overlaps with a file-management operation or shrink operation, a conflict occurs. Regardless of which of the conflicting operations began first, the second operation waits for the lock set by the first operation to time out. (The time-out period is controlled by a session time-out setting.) If the lock is released during the time-out period, the second operation continues. If the lock times out, the second operation fails.

Related tasks

Backup devices and backup media

Create a backup

Note

For partial or copy-only backups, you must use the Transact-SQL BACKUP statement with the PARTIAL or COPY_ONLY option, respectively.