Backup.SqlBackup(Server) Backup.SqlBackup(Server) Backup.SqlBackup(Server) Method

정의

속성에 지정 된 대로 데이터베이스 백업 작업 수행은 Backup 사용 되는 개체입니다. Performs the database backup operation as specified by the properties of the Backup object used.

public:
 void SqlBackup(Microsoft::SqlServer::Management::Smo::Server ^ srv);
public void SqlBackup (Microsoft.SqlServer.Management.Smo.Server srv);
Public Sub SqlBackup (srv As Server)
매개 변수
srv
Server Server Server

Server 백업 작업의 원본인 MicrosoftSQL 서버 인스턴스를 나타내는 개체입니다. The Server object that represents the MicrosoftSQL Server instance that is the source of the backup operation.

예제

VBVB

'Connect to the local, default instance of SQL Server.  
Dim srv As Server  
srv = New Server  
'Reference the AdventureWorks2012 database.  
Dim db As Database  
db = srv.Databases("AdventureWorks2012")  
'Store the current recovery model in a variable.  
Dim recoverymod As Integer  
recoverymod = db.DatabaseOptions.RecoveryModel  
'Define a Backup object variable.   
Dim bk As New Backup  
'Specify the type of backup, the description, the name, and the database to be backed up.  
bk.Action = BackupActionType.Database  
bk.BackupSetDescription = "Full backup of AdventureWorks2012"  
bk.BackupSetName = "AdventureWorks2012 Backup"  
bk.Database = "AdventureWorks2012"  
'Declare a BackupDeviceItem by supplying the backup device file name in the constructor, and the type of device is a file.  
Dim bdi As BackupDeviceItem  
bdi = New BackupDeviceItem("Test_Full_Backup1", DeviceType.File)  
'Add the device to the Backup object.  
bk.Devices.Add(bdi)  
'Set the Incremental property to False to specify that this is a full database backup.  
bk.Incremental = False  
'Set the expiration date.  
Dim backupdate As New Date  
backupdate = New Date(2006, 10, 5)  
bk.ExpirationDate = backupdate  
'Specify that the log must be truncated after the backup is complete.  
bk.LogTruncation = BackupTruncateLogType.Truncate  
'Run SqlBackup to perform the full database backup on the instance of SQL Server.  
bk.SqlBackup(srv)  

PowershellPowershell

$srv = new-Object Microsoft.SqlServer.Management.Smo.Server("(local)")  
$db = New-Object Microsoft.SqlServer.Management.Smo.Database  
$db = $srv.Databases.Item("AdventureWorks2012")  
$recoverymod = $db.DatabaseOptions.RecoveryModel  
$bk = new-object Microsoft.SqlServer.Management.Smo.Backup  
$bk.Action = [Microsoft.SqlServer.Management.Smo.BackupActionType]::Database  
$bk.BackupSetDescription = "Full backup of AdventureWorks2012"  
$bk.BackupSetName = "AdventureWorks2012 Backup"  
$bk.Database = "AdventureWorks2012"  
$bdi = new-object Microsoft.SqlServer.Management.Smo.BackupDeviceItem("Test_Full_Backup1", [Microsoft.SqlServer.Management.Smo.DeviceType]::File)  
$bk.Devices.Add($bdi)  
$bk.Incremental = $FALSE  
$backupDate = new-object System.DateTime(2006, 10, 5)  
$bk.ExpirationDate = $backupDate  
$bk.LogTruncation = [Microsoft.SqlServer.Management.Smo.BackupTruncateLogType]::Truncate  
$bk.SqlBackup($srv)  

설명

SMO( SQL Server Management Objects)를 사용하여 데이터베이스 백업 작업을 수행하려면 응용 프로그램에서 Backup 개체 속성을 설정하여 작업 프로세스를 지정한 다음 SqlBackup 메서드를 호출합니다.To perform a database backup operation using SQL Server Management Objects (SMO), the application specifies the operation process by setting Backup object properties, and then it calls the SqlBackup method.

적용 대상