Partilhar via


Backup Object

Esse recurso será removido em uma versão futura do Microsoft SQL Server. Evite usar esse recurso em desenvolvimentos novos e planeje modificar os aplicativos que atualmente o utilizam.

The Backup object defines a Microsoft SQL Server database or log backup operation.

Modelo de objeto do SQL-DMO mostrando o objeto atual

Comentários

With the Backup object, you can:

  • Back up a SQL Server database or database transaction log.

  • Generate a Transact-SQL BACKUP statement defining a backup.

  • Monitor a backup operation, reporting status to the user.

For SQL Server, a database delimits the largest backup unit. Though many different database backup images can be maintained on any single medium, a backup cannot span more than a single database. By default, backup operations performed with the Backup object back up a complete database.

SQL Server can write a backup to one of the following media types: disk, tape, or a proprietary medium called a backup device. SQL Server supports backup striping. A striped backup is one directed to more than a single device. When striped, a backup is written across the devices in equal chunks. Striping is supported to a single media type only. That is, a backup can be written to two tape devices. However, SQL Server cannot write one-half of a backup to a tape device and the other half to a disk.

At a minimum, you must supply values for a backup source and a backup target when using the Backupobject. The Database property specifies the backup operation source. SQL Distributed Management Objects (SQL-DMO) implements supported media types in the Backup object properties Files, Devices, Pipes, and Tapes. Use one media type property to specify the backup operation target.

To perform a complete database backup

  1. Create a new Backup object.

  2. Set the Database property, naming the database backed up.

  3. Set a media property to name the target device or devices.

  4. Call the SQLBackup method.

In many installations, complete database backup is not a viable option. The Backup object offers access to a number of strategies that ensure data integrity by capturing a subset of the database image.

To back up a database transaction log

  1. Create a new Backup object.

  2. Set the Database property, naming the database backed up.

  3. Set the Action property to SQLDMOBackup_Log.

  4. Set a media property to name the target device or devices.

  5. Call the SQLBackup method.

To perform a differential backup

  1. Create a new Backup object.

  2. Set the Database property, naming the database backed up.

  3. Set the Action property to SQLDMOBackup_Incremental.

  4. Set a media property to name the target device or devices.

  5. Call the SQLBackup method.

To back up specific filegroups

  1. Create a new Backup object.

  2. Set the Database property, naming the database backed up.

  3. Set the DatabaseFileGroups property, naming the filegroup or filegroups providing backup source data.

  4. Set a media property to name the target device or devices.

  5. Call the SQLBackup method.

To back up specific files

  1. Create a new Backup object.

  2. Set the Database property, naming the database backed up.

  3. Set the Action property to SQLDMOBackup_Files.

  4. Set the DatabaseFiles property, naming the file or files providing backup source data.

  5. Set a media property to name the target device or devices.

  6. Call the SQLBackup method.

Settings for any other Backup object properties are optional. Use the optional settings when conditions require extraordinary processing. For example, the MediaName and MediaDescription properties provide, primarily, data used to ensure media availability for tape devices and are applicable when the backup operation defined will initialize the media. For more information about property applicability and use, see individual property documentation.

ObservaçãoObservação

The Backup object is compatible with instances of SQL Server version 7.0 and later. However, the Backup2 object extends the functionality of the Backup object for use with features that were introduced in SQL Server 2000.

Consulte também

Referência