Share via


Bir veritabanını yedekleme

sql-dmo sonraki kaldırılır sürüm Microsoft sql Server'ın.Yeni geliştirme çalışmaları içinde sql-dmo özelliği kullanmaktan kaçının ve sql-dmo kullanan uygulamaları değiştirmek plan.

Veritabanı yedek örnekler karşı tüm veritabanı yedek işlemlerini göstermektedir.

Tüm bir veritabanı yedek işlemini gerçekleştirmek için sql Distributed Management Objects (sql-dmo) kullanırken, yedek kullanılan nesne sağlar, en az bir kaynak veritabanı ve hedef aygıt.A yedek karşı tüm veritabanı can (tam) tüm verileri yedekleyin veya bu verileri değişti sonra son yedek (fark).

Kullanılan veritabanı yedek veritabanı işlem günlüğünün yedek veritabanı bakım planının bir parçası değil.Küçük veritabanları ve değişmeyen veritabanları veritabanı yedek için iyi hedefleri şunlardır.Bu koşullar doğru olduğunda normal tam yedek veya başlangıç bir tam yedek ve izleyen, zaman zaman farklı yedeklemeler, çoğu durumda veri güvenli bir şekilde koruyabilirsiniz.

Örnekler

A.Performing a Complete Database Backup

Bu örnekte tam bir veritabanı için sql-dmo kullanmayı göstermektedir yedek.

' Create a Backup object and set action and source database properties.
Dim oBackup As New SQLDMO.Backup
oBackup.Action = SQLDMOBackup_Database
oBackup.Database = "Northwind"

' Example illustrates a striped backup using two target devices. Note:
' Device creation is not illustrated in this example.
oBackup.Devices = "[NorthDev1],[NorthDev2]"

' Optional. Backup set name and description properties provide
' descriptive text when backup header is displayed for the device(s).
oBackup.BackupSetName = "Northwind_Full"
oBackup.BackupSetDescription = "Full backup of Northwind sample."

' Call SQLBackup method to perform the backup. In a production
' environment, consider wrapping the method call with a wait pointer
' or use Backup object events to provide feedback to the user.
'
' Note: Create and connect of SQLServer object used is not
' illustrated in this example.
oBackup.SQLBackup oSQLServer

B.Performing a Differential Backup on a Database

Bu örnek sql-dmo fark veritabanı gerçekleştirmek için örnekler yedek.

' Create a Backup object and set action and source database properties.
Dim oBackup As New SQLDMO.Backup
oBackup.Action = SQLDMOBackup_Differential
oBackup.Database = "Northwind"

' Example illustrates backup implemented to a single operating system
' file. A file naming convention could be easily applied allowing
' rapid identification of a specific differential backup.
oBackup.Files = _
    "c:\program files\microsoft sql server\mssql\backup\NorthDiff.bak"

' Optional. When backup is directed to one or more files, set media
' name, backup set name and description to provide in-file 
' documentation of the file and backup set contained.
oBackup.MediaName = "NorthDiff.bak " & Date & " " & Time
oBackup.BackupSetName = "NorthDiff"
oBackup.BackupSetDescription = _
    "Differential backup of Northwind sample."

' Call SQLBackup method to perform the backup. In a production
' environment, consider wrapping the method call with a wait pointer
' or use Backup object events to provide feedback to the user.
'
' Note: Create and connect of SQLServer object used is not
' illustrated in this example.
oBackup.SQLBackup oSQLServer

Ayrıca bkz.

Başvuru