Author | Stuart Moore (@napalmgram), stuart-moore.com |
Availability | Windows, Linux, macOS |
Want to see the source code for this command? Check out Invoke-DbaAdvancedRestore on GitHub.
Want to see the Bill Of Health for this command? Check out Invoke-DbaAdvancedRestore.
Allows the restore of modified BackupHistory Objects
For 90% of users Restore-DbaDatabase should be your point of access to this function. The other 10% use it at their own risk
This is the final piece in the Restore-DbaDatabase Stack. Usually a BackupHistory object will arrive here from Restore-DbaDatabase
via the following pipeline:
Get-DbaBackupInformation | Select-DbaBackupInformation | Format-DbaBackupInformation | Test-DbaBackupInformation | Invoke-DbaAdvancedRestore
We have exposed these functions publicly to allow advanced users to perform operations that we don't support, or won't add as they would make things too complex for the majority of our users
For example if you wanted to do some very complex redirection during a migration, then doing the rewrite of destinations may be better done with your own custom scripts rather than via Format-DbaBackupInformation
We would recommend ALWAYS pushing your input through Test-DbaBackupInformation
just to make sure that it makes sense to us.
Invoke-DbaAdvancedRestore
[-BackupHistory] <Object[]>
[[-SqlInstance] <DbaInstanceParameter>]
[[-SqlCredential] <PSCredential>]
[-OutputScriptOnly]
[-VerifyOnly]
[[-RestoreTime] <DateTime>]
[[-StandbyDirectory] <String>]
[-NoRecovery]
[[-MaxTransferSize] <Int32>]
[[-BlockSize] <Int32>]
[[-BufferCount] <Int32>]
[-Continue]
[[-AzureCredential] <String>]
[-WithReplace]
[-KeepReplication]
[-KeepCDC]
[[-PageRestore] <Object[]>]
[[-ExecuteAs] <String>]
[-StopBefore]
[[-StopMark] <String>]
[[-StopAfterDate] <DateTime>]
[-EnableException]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
PS C:\> $BackupHistory | Invoke-DbaAdvancedRestore -SqlInstance MyInstance
Will restore all the backups in the BackupHistory object according to the transformations it contains
PS C:\> $BackupHistory | Invoke-DbaAdvancedRestore -SqlInstance MyInstance -OutputScriptOnly
PS C:\> $BackupHistory | Invoke-DbaAdvancedRestore -SqlInstance MyInstance
First generates just the T-SQL restore scripts so they can be sanity checked, and then if they are good perform the full restore.
By reusing the BackupHistory object there is no need to rescan all the backup files again
The BackupHistory object to be restored.
Can be passed in on the pipeline
Alias | |
Required | True |
Pipeline | true (ByValue) |
Default Value |
The SqlInstance to which the backups should be restored
Alias | |
Required | False |
Pipeline | false |
Default Value |
Login to the target instance using alternative credentials. Accepts PowerShell credentials (Get-Credential).
Windows Authentication, SQL Server Authentication, Active Directory - Password, and Active Directory - Integrated are all supported.
For MFA support, please use Connect-DbaInstance.
Alias | |
Required | False |
Pipeline | false |
Default Value |
If set, the restore will not be performed, but the T-SQL scripts to perform it will be returned
Alias | |
Required | False |
Pipeline | false |
Default Value | False |
If set, performs a Verify of the backups rather than a full restore
Alias | |
Required | False |
Pipeline | false |
Default Value | False |
Point in Time to which the database should be restored.
This should be the same value or earlier, as used in the previous pipeline stages
Alias | |
Required | False |
Pipeline | false |
Default Value | (Get-Date).AddDays(2) |
A folder path where a standby file should be created to put the recovered databases in a standby mode
Alias | |
Required | False |
Pipeline | false |
Default Value |
Leave the database in a restoring state so that further restore may be made
Alias | |
Required | False |
Pipeline | false |
Default Value | False |
Parameter to set the unit of transfer. Values must be a multiple by 64kb
Alias | |
Required | False |
Pipeline | false |
Default Value | 0 |
Specifies the block size to use. Must be one of 0.5kb,1kb,2kb,4kb,8kb,16kb,32kb or 64kb
Can be specified in bytes
Refer to https://msdn.microsoft.com/en-us/library/ms178615.aspx for more detail
Alias | |
Required | False |
Pipeline | false |
Default Value | 0 |
Number of I/O buffers to use to perform the operation.
Refer to https://msdn.microsoft.com/en-us/library/ms178615.aspx for more detail
Alias | |
Required | False |
Pipeline | false |
Default Value | 0 |
Indicates that the restore is continuing a restore, so target database must be in Recovering or Standby states
When specified, WithReplace will be set to true
Alias | |
Required | False |
Pipeline | false |
Default Value | False |
AzureCredential required to connect to blob storage holding the backups
Alias | |
Required | False |
Pipeline | false |
Default Value |
Indicated that if the database already exists it should be replaced
Alias | |
Required | False |
Pipeline | false |
Default Value | False |
Indicates whether replication configuration should be restored as part of the database restore operation
Alias | |
Required | False |
Pipeline | false |
Default Value | False |
Indicates whether CDC information should be restored as part of the database
Alias | |
Required | False |
Pipeline | false |
Default Value | False |
The output from Get-DbaSuspect page containing the suspect pages to be restored.
Alias | |
Required | False |
Pipeline | false |
Default Value |
If set, this will cause the database(s) to be restored (and therefore owned) as the SA user
Alias | |
Required | False |
Pipeline | false |
Default Value |
Switch to indicate the restore should stop before StopMark
Alias | |
Required | False |
Pipeline | false |
Default Value | False |
Mark in the transaction log to stop the restore at
Alias | |
Required | False |
Pipeline | false |
Default Value |
By default the restore will stop at the first occurence of StopMark found in the chain, passing a datetime where will cause it to stop the first StopMark atfer that datetime
Alias | |
Required | False |
Pipeline | false |
Default Value |
By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.
This avoids overwhelming you with "sea of red" exceptions, but is inconvenient because it basically disables advanced scripting.
Using this switch turns this "nice by default" feature off and enables you to catch exceptions with your own try/catch.
Alias | |
Required | False |
Pipeline | false |
Default Value | False |
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Alias | wi |
Required | False |
Pipeline | false |
Default Value |
Prompts you for confirmation before running the cmdlet.
Alias | cf |
Required | False |
Pipeline | false |
Default Value |