共用方式為


Backup.CopyOnly 屬性

Gets or sets a Boolean property value that specifies the backup is a copy-only backup. This does not affect the sequence of backups in the usual backup schedule.

命名空間:  Microsoft.SqlServer.Management.Smo
組件:  Microsoft.SqlServer.SmoExtended (在 Microsoft.SqlServer.SmoExtended.dll 中)

語法

'宣告
Public Property CopyOnly As Boolean 
    Get 
    Set
'用途
Dim instance As Backup 
Dim value As Boolean 

value = instance.CopyOnly

instance.CopyOnly = value
public bool CopyOnly { get; set; }
public:
property bool CopyOnly {
    bool get ();
    void set (bool value);
}
member CopyOnly : bool with get, set
function get CopyOnly () : boolean 
function set CopyOnly (value : boolean)

屬性值

型別:System.Boolean
A Boolean value that specifies whether the backup is a copy-only backup.If True, the backup is a copy-only backup.If False (default), the backup is not a copy-only backup, and is part of the usual sequence of backups.

備註

A copy-only backup does not affect your overall backup and restore procedures for the database.

Copy-only backups were introduced in SQL Server 2005 for use in situations in which a backup is taken for a special purpose, such as backing up the log before an online file restore. Typically, a copy-only log backup is used one time and then deleted.

範例

VB

'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")
Dim bk As New Backup
bk.Action = BackupActionType.Database
bk.Database = "AdventureWorks2012"
bk.CopyOnly = true

PowerShell

$srv = new-Object Microsoft.SqlServer.Management.Smo.Server("(local)")
$db = New-Object Microsoft.SqlServer.Management.Smo.Database
$db = $srv.Databases.Item("AdventureWorks2012")
$bk = new-object Microsoft.SqlServer.Management.Smo.Backup
$bk.Action = [Microsoft.SqlServer.Management.Smo.BackupActionType]::Database
$bk.Database = "AdventureWorks2012"
$bk.CopyOnly = $TRUE

請參閱

參考

Backup 類別

Microsoft.SqlServer.Management.Smo 命名空間

其他資源

差異備份 (SQL Server)

BACKUP (Transact-SQL)

備份及還原資料庫和交易記錄