Backup-SqlDatabase

Backs up SQL Server database objects.

语法

ByPath (默认值)

Backup-SqlDatabase
    [-Database] <String>
    [[-BackupFile] <String[]>]
    [-BackupContainer <String>]
    [-MirrorDevices <BackupDeviceList[]>]
    [-BackupAction <BackupActionType>]
    [-BackupSetName <String>]
    [-BackupSetDescription <String>]
    [-CompressionOption <BackupCompressionOptions>]
    [-CopyOnly]
    [-ExpirationDate <DateTime>]
    [-FormatMedia]
    [-Incremental]
    [-Initialize]
    [-LogTruncationType <BackupTruncateLogType>]
    [-MediaDescription <String>]
    [-RetainDays <Int32>]
    [-SkipTapeHeader]
    [-UndoFileName <String>]
    [-EncryptionOption <BackupEncryptionOptions>]
    [-StatementTimeout <Int32>]
    [-Path <String[]>]
    [-SqlCredential <PSObject>]
    [-BackupDevice <BackupDeviceItem[]>]
    [-PassThru]
    [-Checksum]
    [-ContinueAfterError]
    [-NoRewind]
    [-Restart]
    [-UnloadTapeAfter]
    [-NoRecovery]
    [-DatabaseFile <String[]>]
    [-DatabaseFileGroup <String[]>]
    [-BlockSize <Int32>]
    [-BufferCount <Int32>]
    [-MaxTransferSize <Int32>]
    [-MediaName <String>]
    [-Script]
    [-AccessToken <PSObject>]
    [-TrustServerCertificate]
    [-HostNameInCertificate <String>]
    [-Encrypt <String>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

ByDBObject

Backup-SqlDatabase
    [-DatabaseObject] <Database>
    [[-BackupFile] <String[]>]
    [-BackupContainer <String>]
    [-MirrorDevices <BackupDeviceList[]>]
    [-BackupAction <BackupActionType>]
    [-BackupSetName <String>]
    [-BackupSetDescription <String>]
    [-CompressionOption <BackupCompressionOptions>]
    [-CopyOnly]
    [-ExpirationDate <DateTime>]
    [-FormatMedia]
    [-Incremental]
    [-Initialize]
    [-LogTruncationType <BackupTruncateLogType>]
    [-MediaDescription <String>]
    [-RetainDays <Int32>]
    [-SkipTapeHeader]
    [-UndoFileName <String>]
    [-EncryptionOption <BackupEncryptionOptions>]
    [-StatementTimeout <Int32>]
    [-SqlCredential <PSObject>]
    [-BackupDevice <BackupDeviceItem[]>]
    [-PassThru]
    [-Checksum]
    [-ContinueAfterError]
    [-NoRewind]
    [-Restart]
    [-UnloadTapeAfter]
    [-NoRecovery]
    [-DatabaseFile <String[]>]
    [-DatabaseFileGroup <String[]>]
    [-BlockSize <Int32>]
    [-BufferCount <Int32>]
    [-MaxTransferSize <Int32>]
    [-MediaName <String>]
    [-Script]
    [-AccessToken <PSObject>]
    [-TrustServerCertificate]
    [-HostNameInCertificate <String>]
    [-Encrypt <String>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

ByName

Backup-SqlDatabase
    [-Database] <String>
    [[-BackupFile] <String[]>]
    -ServerInstance <String[]>
    [-BackupContainer <String>]
    [-MirrorDevices <BackupDeviceList[]>]
    [-BackupAction <BackupActionType>]
    [-BackupSetName <String>]
    [-BackupSetDescription <String>]
    [-CompressionOption <BackupCompressionOptions>]
    [-CopyOnly]
    [-ExpirationDate <DateTime>]
    [-FormatMedia]
    [-Incremental]
    [-Initialize]
    [-LogTruncationType <BackupTruncateLogType>]
    [-MediaDescription <String>]
    [-RetainDays <Int32>]
    [-SkipTapeHeader]
    [-UndoFileName <String>]
    [-EncryptionOption <BackupEncryptionOptions>]
    [-StatementTimeout <Int32>]
    [-Credential <PSCredential>]
    [-ConnectionTimeout <Int32>]
    [-SqlCredential <PSObject>]
    [-BackupDevice <BackupDeviceItem[]>]
    [-PassThru]
    [-Checksum]
    [-ContinueAfterError]
    [-NoRewind]
    [-Restart]
    [-UnloadTapeAfter]
    [-NoRecovery]
    [-DatabaseFile <String[]>]
    [-DatabaseFileGroup <String[]>]
    [-BlockSize <Int32>]
    [-BufferCount <Int32>]
    [-MaxTransferSize <Int32>]
    [-MediaName <String>]
    [-Script]
    [-AccessToken <PSObject>]
    [-TrustServerCertificate]
    [-HostNameInCertificate <String>]
    [-Encrypt <String>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

ByObject

Backup-SqlDatabase
    [-Database] <String>
    [[-BackupFile] <String[]>]
    -InputObject <Server[]>
    [-BackupContainer <String>]
    [-MirrorDevices <BackupDeviceList[]>]
    [-BackupAction <BackupActionType>]
    [-BackupSetName <String>]
    [-BackupSetDescription <String>]
    [-CompressionOption <BackupCompressionOptions>]
    [-CopyOnly]
    [-ExpirationDate <DateTime>]
    [-FormatMedia]
    [-Incremental]
    [-Initialize]
    [-LogTruncationType <BackupTruncateLogType>]
    [-MediaDescription <String>]
    [-RetainDays <Int32>]
    [-SkipTapeHeader]
    [-UndoFileName <String>]
    [-EncryptionOption <BackupEncryptionOptions>]
    [-StatementTimeout <Int32>]
    [-SqlCredential <PSObject>]
    [-BackupDevice <BackupDeviceItem[]>]
    [-PassThru]
    [-Checksum]
    [-ContinueAfterError]
    [-NoRewind]
    [-Restart]
    [-UnloadTapeAfter]
    [-NoRecovery]
    [-DatabaseFile <String[]>]
    [-DatabaseFileGroup <String[]>]
    [-BlockSize <Int32>]
    [-BufferCount <Int32>]
    [-MaxTransferSize <Int32>]
    [-MediaName <String>]
    [-Script]
    [-AccessToken <PSObject>]
    [-TrustServerCertificate]
    [-HostNameInCertificate <String>]
    [-Encrypt <String>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

ByBackupContainer

Backup-SqlDatabase
    [[-BackupFile] <String[]>]
    [-BackupContainer <String>]
    [-MirrorDevices <BackupDeviceList[]>]
    [-BackupAction <BackupActionType>]
    [-BackupSetName <String>]
    [-BackupSetDescription <String>]
    [-CompressionOption <BackupCompressionOptions>]
    [-CopyOnly]
    [-ExpirationDate <DateTime>]
    [-FormatMedia]
    [-Incremental]
    [-Initialize]
    [-LogTruncationType <BackupTruncateLogType>]
    [-MediaDescription <String>]
    [-RetainDays <Int32>]
    [-SkipTapeHeader]
    [-UndoFileName <String>]
    [-EncryptionOption <BackupEncryptionOptions>]
    [-StatementTimeout <Int32>]
    [-SqlCredential <PSObject>]
    [-BackupDevice <BackupDeviceItem[]>]
    [-PassThru]
    [-Checksum]
    [-ContinueAfterError]
    [-NoRewind]
    [-Restart]
    [-UnloadTapeAfter]
    [-NoRecovery]
    [-DatabaseFile <String[]>]
    [-DatabaseFileGroup <String[]>]
    [-BlockSize <Int32>]
    [-BufferCount <Int32>]
    [-MaxTransferSize <Int32>]
    [-MediaName <String>]
    [-Script]
    [-AccessToken <PSObject>]
    [-TrustServerCertificate]
    [-HostNameInCertificate <String>]
    [-Encrypt <String>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

说明

The Backup-SqlDatabase cmdlet performs backup operations on a SQL Server database.

This includes full database backups, transaction log backups, and database file backups.

This cmdlet is modeled after the Microsoft.SqlServer.Management.Smo.Backup class.

The parameters on this class generally correspond to properties on that Smo object.

To back up a database by server instance path and database name, specify the server instance path in the Path parameter and the database name in the Database parameter.

To back up a database using an Smo.Server object and database name, specify the Smo.Server object in the InputObject parameter, either directly or by using the pipeline operator, and the database name in the Database parameter.

To back up a database by server instance and database name, specify the server instance in the ServerInstance parameter and the database name in the Database parameter.

To back up a database using an Smo.Database object, specify the Smo.Database object in the DatabaseObject parameter, either directly or by using the pipeline operator.

By default this cmdlet performs a full database backup.

Set the type of the backup by using the BackupAction parameter.

By default the backup file is stored in the default server backup location under the name databasename.bak for full and/or file backups and under the name databasename.trn for log backups. To specify a different file name, use the BackupFile parameter.

To specify a backup file location and use an auto-generated file name, specify the location by using the BackupContainer parameter.

示例

Example 1: Backup a complete database

PS C:\> Backup-SqlDatabase -ServerInstance "Computer\Instance" -Database "MainDB"

This command creates a complete database backup of the database named 'MainDB' to the default backup location of the server instance 'Computer\Instance'. The backup file is named 'MainDB.bak'.

Example 2: Backup a database based on location

PS C:\> Set-Location "SQLSERVER:\SQL\Computer\Instance"
PS SQLSERVER:\SQL\Computer\Instance> Backup-SqlDatabase -Database "MainDB"

This command creates a complete database backup of the database 'MainDB' to the default backup location of the server instance 'Computer\Instance'. The current working directory is used to determine the server instance where the backup occurs.

Example 3: Backup the transaction log

PS C:\> Backup-SqlDatabase -ServerInstance "Computer\Instance" -Database "MainDB" -BackupAction Log

This command creates a backup of the transaction log of the database 'MainDB' to the default backup location of the server instance 'Computer\Instance'. The backup file is named 'MainDB.trn'.

Example 4: Backup a database and prompt for credentials

PS C:\> Backup-SqlDatabase -ServerInstance "Computer\Instance" -Database "MainDB" -Credential (Get-Credential "sa")

This command creates a complete database backup of the database 'MainDB' using the 'sa' SQL Server login. This command prompts for a password to complete the authentication.

Example 5: Backup a database to a network file share

PS C:\> Backup-SqlDatabase -ServerInstance "Computer\Instance" -Database "MainDB" -BackupFile "\\mainserver\databasebackup\MainDB.bak"

This command creates a complete database backup of the database 'MainDB' to the file "\\mainserver\databasebackup\MainDB.bak".

Example 6: Backup all databases in a server instance

PS C:\> Get-ChildItem "SQLSERVER:\SQL\Computer\Instance\Databases" | Backup-SqlDatabase

This command backs up all databases on the server instance 'Computer\Instance' to the default backup location. The backup files are named <database name>.bak.

Example 7: Backup all databases in a server instance to a network file share

PS C:\> Set-Location "SQLSERVER:\SQL\Computer\Instance\Databases"
PS SQLSERVER:\SQL\Computer\Instance\Databases> foreach ($database in (Get-ChildItem)) {
     $dbName = $database.Name
     Backup-SqlDatabase -Database $dbName -BackupFile "\\mainserver\databasebackup\$dbName.bak" }

This command creates a full backup for each database on the server instance 'Computer\Instance' to the share "\\mainserver\databasebackup". The backup files are named <database name>.bak.

Example 8: Backup all files in secondary file groups

PS C:\> Backup-SqlDatabase -ServerInstance "Computer\Instance" -Database "MainDB" -BackupAction Files -DatabaseFileGroup "FileGroupJan","FileGroupFeb"

This command creates a full file backup of every file in the secondary filegroups 'FileGroupJan' and 'FileGroupFeb'.

Example 9: Create a differential backup

PS C:\> Backup-SqlDatabase -ServerInstance "Computer\Instance" -Database "MainDB" -Incremental

This command creates a differential backup of the database 'MainDB' to the default backup location of the server instance 'Computer\Instance'. The backup file is named "MainDB.bak".

Example 10: Create a backup to a tape drive

PS C:\> $TapeDevice = New-Object Microsoft.Sqlserver.Management.Smo.BackupDeviceItem("\\.\tape0", "Tape")
PS C:\> Backup-SqlDatabase -ServerInstance "Computer\Instance" -Database "MainDB" -BackupDevice $TapeDevice

This command creates a full backup of the database MainDB to the tape device "\\.\tape0". To represent this device, the command constructs an instance of the Microsoft.Sqlserver.Management.Smo.BackupDeviceItem object. The constructor takes two arguments, the name of the backup device and the type of the backup device. This BackupDeviceItem object is passed to the BackupDevice parameter of the Backup-SqlDatabase cmdlet.

Example 11: Backup a database to the Azure Blob Storage service

PS C:\> Backup-SqlDatabase -ServerInstance "Computer\Instance" -Database "MainDB" -BackupContainer "https://storageaccountname.blob.core.windows.net/containername" -SqlCredential "SQLCredentialName"

This command creates a full backup of the database 'MainDB' to the Windows Azure Blob Storage service. It uses BackupContainer to specify the location (URL) of the Windows Azure Blob container. The name of the backup file is auto-generated. The SqlCredential parameter is used to specify the name of the SQL Server credential that stores the authentication information.

Example 12: Backup a database to the Azure Blob Storage service and specify the file name

PS C:\> Backup-SqlDatabase -ServerInstance "Computer\Instance" -Database "MainyDB" -BackupFile "https://storageaccountname.blob.core.windows.net/containername/MainDB.bak" -SqlCredential "SQLCredentialName"

This command creates a full backup of the database MainDB to the Windows Azure Blob Storage service. It uses the BackupFile parameter to specify the location (URL) and the backup file name. The SqlCredential parameter is used to specify the name of the SQL Server credential.

Example 13: Backup all databases to the Azure Blob Storage service

PS C:\> Get-ChildItem "SQLSERVER:\SQL\Computer\Instance\Databases" | Backup-SqlDatabase -BackupContainer "https://storageaccountname.blob.core.windows.net/containername" -SqlCredential "SQLCredentialName"

This command backs up all databases on the server instance 'Computer\Instance' to the Windows Azure Blob Storage service location by using the BackupContainer parameter. The backup file names are auto generated.

Example 14: Create an encrypted backup

PS C:\> $EncryptionOption = New-SqlBackupEncryptionOption -Algorithm Aes256 -EncryptorType ServerCertificate -EncryptorName "BackupCert"
PS C:\> Backup-SqlDatabase -ServerInstance "." -Database "MainDB" -BackupFile "MainDB.bak" -CompressionOption On -EncryptionOption $EncryptionOption

This example creates the encryption options and uses it as a parameter value in Backup-SqlDatabase to create an encrypted backup.

参数

-AccessToken

The access token used to authenticate to SQL Server, as an alternative to user/password or Windows Authentication.

This can be used, for example, to connect to SQL Azure DB and SQL Azure Managed Instance using a Service Principal or a Managed Identity.

The parameter to use can be either a string representing the token or a PSAccessToken object as returned by running Get-AzAccessToken -ResourceUrl https://database.windows.net.

This parameter is new in v22 of the module.

参数属性

类型:PSObject
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-BackupAction

Specifies the type of backup operation to perform. Valid values are:

  • Database. Backs up all the data files in the database.
  • Files. Backs up data files specified in the DatabaseFile or DatabaseFileGroup parameters.
  • Log. Backs up the transaction log.

参数属性

类型:BackupActionType
默认值:None
接受的值:Database, Files, Log
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-BackupContainer

Specifies the folder or location where the cmdlet stores backups. This can be a folder on a disk or URL for an Azure Blob container. This parameter can be useful when backing up multiple databases in a given instance. This parameter cannot be used with a BackupDevice parameter. The BackupContainer parameter cannot be used with the BackupFile parameter.

The path used to specify the location should end with a forward slash (/).

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-BackupDevice

Specifies the devices where the backups are stored. This parameter cannot be used with the BackupFile parameter. Use this parameter if you are backing up to tape.

参数属性

类型:

BackupDeviceItem[]

默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-BackupFile

Specifies the location and filename(s) for the backup.

This is an optional parameter.

If not specified, the backups are stored in the default backup location of the server under the name databasename.bak for full and file backups, or databasename.trn for log backups.

When backing up to multiple files, separate the filenames with commas, for example: -BackupFile C:\Backups\databasename2.bak,C:\Backups\databasename2.bak

This parameter cannot be used with the -BackupDevice or -BackupContainer parameters.

参数属性

类型:

String[]

默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:2
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-BackupSetDescription

Specifies the description of the backup set. This parameter is optional.

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-BackupSetName

Specifies the name of the backup set.

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-BlockSize

Specifies the physical block size for the backup, in bytes. The supported sizes are 512, 1024, 2048, 4096, 8192, 16384, 32768, and 65536 (64 KB) bytes. The default is 65536 for tape devices and 512 for all other devices.

参数属性

类型:Int32
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-BufferCount

Specifies the number of I/O buffers to use for the backup operation. You can specify any positive integer. If there is insufficient virtual address space in the Sqlservr.exe process for the buffers, you will receive an out of memory error.

参数属性

类型:Int32
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-Checksum

Indicates that a checksum value is calculated during the backup operation.

参数属性

类型:SwitchParameter
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-CompressionOption

Specifies the compression options for the backup operation.

参数属性

类型:BackupCompressionOptions
默认值:None
接受的值:Default, On, Off
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-Confirm

Prompts you for confirmation before running the cmdlet.Prompts you for confirmation before running the cmdlet.

参数属性

类型:SwitchParameter
默认值:False
支持通配符:False
不显示:False
别名:cf

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-ConnectionTimeout

Specifies the number of seconds to wait for a server connection before a timeout failure. The timeout value must be an integer between 0 and 65534. If 0 is specified, connection attempts do not timeout.

参数属性

类型:Int32
默认值:None
支持通配符:False
不显示:False

参数集

ByName
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-ContinueAfterError

Indicates that the operation continues when a checksum error occurs. If not set, the operation will fail after a checksum error.

参数属性

类型:SwitchParameter
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-CopyOnly

Indicates that the backup is a copy-only backup. A copy-only backup does not affect the normal sequence of your regularly scheduled conventional backups.

参数属性

类型:SwitchParameter
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-Credential

Specifies a PSCredential object that contains the credentials for a SQL Server login that has permission to perform this operation. This is not the SQL credential object that is used to store authentication information internally by SQL Server when accessing resources outside SQL Server.

参数属性

类型:PSCredential
默认值:None
支持通配符:False
不显示:False

参数集

ByName
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-Database

Specifies the name of the database to back up. This parameter cannot be used with the DatabaseObject parameter. When this parameter is specified, the Path, InputObject, or ServerInstance parameters must also be specified.

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

ByPath
Position:1
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
ByName
Position:1
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
ByObject
Position:1
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-DatabaseFile

Specifies one or more database files to back up. This parameter is only used when BackupAction is set to Files. When BackupAction is set to Files, either the DatabaseFileGroups or DatabaseFiles parameter must be specified.

参数属性

类型:

String[]

默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-DatabaseFileGroup

Specifies the database file groups targeted by the backup operation. This parameter is only used when BackupAction property is set to Files. When BackupAction parameter is set to Files, either the DatabaseFileGroups or DatabaseFiles parameter must be specified.

参数属性

类型:

String[]

默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-DatabaseObject

Specifies the database object for the backup operation.

参数属性

类型:Database
默认值:None
支持通配符:False
不显示:False

参数集

ByDBObject
Position:1
必需:True
来自管道的值:True
来自管道的值(按属性名称):False
来自剩余参数的值:False

-Encrypt

The encryption type to use when connecting to SQL Server.

This value maps to the Encrypt property SqlConnectionEncryptOption on the SqlConnection object of the Microsoft.Data.SqlClient driver.

In v22 of the module, the default is Optional (for compatibility with v21). In v23+ of the module, the default value will be 'Mandatory', which may create a breaking change for existing scripts.

This parameter is new in v22 of the module.

参数属性

类型:String
默认值:None
接受的值:Mandatory, Optional, Strict
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-EncryptionOption

Specifies the encryption options for the backup operation.

参数属性

类型:BackupEncryptionOptions
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-ExpirationDate

Specifies the date and time when the backup set expires and the backup data is no longer considered valid. This can only be used for backup data stored on disk or tape devices. Backup sets older than the expiration date are available to be overwritten by a later backup.

参数属性

类型:DateTime
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-FormatMedia

Indicates that the tape is formatted as the first step of the backup operation. This doesnot apply to a disk backup.

参数属性

类型:SwitchParameter
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-HostNameInCertificate

The host name to be used in validating the SQL Server TLS/SSL certificate. You must pass this parameter if your SQL Server instance is enabled for Force Encryption and you want to connect to an instance using hostname/shortname. If this parameter is omitted then passing the Fully Qualified Domain Name (FQDN) to -ServerInstance is necessary to connect to a SQL Server instance enabled for Force Encryption.

This parameter is new in v22 of the module.

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-Incremental

Indicates that a differential backup is performed.

参数属性

类型:SwitchParameter
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-Initialize

Indicates that devices associated with the backup operation are initialized. This overwrites any existing backup sets on the media and makes this backup the first backup set on the media.

参数属性

类型:SwitchParameter
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-InputObject

Specifies the server object for the backup location.

参数属性

类型:

Server[]

默认值:None
支持通配符:False
不显示:False

参数集

ByObject
Position:Named
必需:True
来自管道的值:True
来自管道的值(按属性名称):False
来自剩余参数的值:False

-LogTruncationType

Specifies the truncation behavior for log backups. Valid values are:

-- TruncateOnly -- NoTruncate -- Truncate

The default value is Truncate.

参数属性

类型:BackupTruncateLogType
默认值:None
接受的值:TruncateOnly, NoTruncate, Truncate
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-MaxTransferSize

Specifies the maximum number of bytes to be transferred between the backup media and the instance of SQL Server. The possible values are multiples of 65536 bytes (64 KB), up to 4194304 bytes (4 MB).

参数属性

类型:Int32
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-MediaDescription

Specifies the description for the medium that contains the backup set. This parameter is optional.

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-MediaName

Specifies the name used to identify the media set.

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-MirrorDevices

Specifies an array of BackupDeviceList objects used by the mirrored backup.

参数属性

类型:

BackupDeviceList[]

默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-NoRecovery

Indicates that the tail end of the log is not backed up. When restored, the database is in the restoring state. When not set, the tail end of the log is backed up. This only applies when the BackupAction parameter is set to Log.

参数属性

类型:SwitchParameter
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-NoRewind

Indicates that a tape drive is left open at the ending position when the backup completes. When not set, the tape is rewound after the operation completes. This does not apply to disk or URL backups.

参数属性

类型:SwitchParameter
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-PassThru

Indicates that the cmdlet outputs the Smo.Backup object that performed the backup.

参数属性

类型:SwitchParameter
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-Path

Specifies the path to the instance of SQL Server to execute the backup operation. This is an optional parameter. If not specified, the value of this parameter defaults to the current working location.

参数属性

类型:

String[]

默认值:None
支持通配符:False
不显示:False

参数集

ByPath
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-Restart

Indicates that the cmdlet continues processing a partially completed backup operation. If not set, the cmdlet restarts an interrupted backup operation at the beginning of the backup set.

参数属性

类型:SwitchParameter
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-RetainDays

Specifies the number of days that must elapse before a backup set can be overwritten. This can only be used for backup data stored on disk or tape devices.

参数属性

类型:Int32
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-Script

Indicates that this cmdlet outputs a Transact-SQL script that performs the backup operation.

参数属性

类型:SwitchParameter
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-ServerInstance

Specifies the name of a SQL Server instance. This server instance becomes the target of the backup operation.

参数属性

类型:

String[]

默认值:None
支持通配符:False
不显示:False

参数集

ByName
Position:Named
必需:True
来自管道的值:True
来自管道的值(按属性名称):True
来自剩余参数的值:False

-SkipTapeHeader

Indicates that the tape header is not read.

参数属性

类型:SwitchParameter
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-SqlCredential

Specifies an SQL Server credential object that stores authentication information. If you are backing up to Blob storage service, you must specify this parameter. The authentication information stored includes the Storage account name and the associated access key values. Do not specify this parameter for disk or tape.

参数属性

类型:PSObject
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-StatementTimeout

Set the timeout (in seconds) for the back-up operation.

If the value is 0 or the StatementTimeout parameter is not specified, the restore operation is not going to timeout.

参数属性

类型:Int32
默认值:0
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-TrustServerCertificate

Indicates whether the channel will be encrypted while bypassing walking the certificate chain to validate trust.

In v22 of the module, the default is $true (for compatibility with v21). In v23+ of the module, the default value will be '$false', which may create a breaking change for existing scripts.

This parameter is new in v22 of the module.

参数属性

类型:SwitchParameter
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-UndoFileName

Specifies the name of the undo file used to store uncommitted transactions that are rolled back during recovery.

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-UnloadTapeAfter

Indicates that the tape device is rewound and unloaded when the operation finishes. If not set, no attempt is made to rewind and unload the tape medium. This does not apply to disk or URL backups.

参数属性

类型:SwitchParameter
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.Shows what would happen if the cmdlet runs. The cmdlet is not run.

参数属性

类型:SwitchParameter
默认值:False
支持通配符:False
不显示:False
别名:wi

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

输入

SMO.Server

Microsoft.SqlServer.Management.Smo.Database

Microsoft.SqlServer.Management.Smo.Server

Specifies an SMO.Server object referring to the instance of SQL Server on which the backup operation occurs.

System.String

输出

System.Object