< Back
Invoke-DbaAdvancedRestore
Post
NAME Invoke-DbaAdvancedRestore
SYNOPSIS
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
SYNTAX
Invoke-DbaAdvancedRestore [-BackupHistory] <System.Object[]> [[-SqlInstance] <DbaInstanceParameter>]
[[-SqlCredential] <Pscredential>] [-OutputScriptOnly <Switch>] [-VerifyOnly <Switch>] [[-RestoreTime] <Datetime>]
[[-StandbyDirectory] <String>] [-NoRecovery <Switch>] [[-MaxTransferSize] <Int>] [[-BlockSize] <Int>]
[[-BufferCount] <Int>] [-Continue <Switch>] [[-AzureCredential] <String>] [-WithReplace <Switch>]
[-KeepReplication <Switch>] [-KeepCDC <Switch>] [[-PageRestore] <System.Object[]>] [-EnableException <Switch>]
[<CommonParameters>]
DESCRIPTION
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.
PARAMETERS
-AzureCredential [<String>]
AzureCredential required to connect to blob storage holding the backups
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-BackupHistory [<System.Object[]>]
The BackupHistory object to be restored.
Can be passed in on the pipeline
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-BlockSize [<Int>]
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
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-BufferCount [<Int>]
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
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-Continue [<Switch>]
Indicates that the restore is continuing a restore, so target database must be in Recovering or Standby states
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-EnableException [<Switch>]
Replaces user friendly yellow warnings with bloody red exceptions of doom!
Use this if you want the function to throw terminating errors you want to catch.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-KeepCDC [<Switch>]
Indicates whether CDC information should be restored as part of the database
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-KeepReplication [<Switch>]
Indicates whether replication configuration should be restored as part of the database restore operation
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-MaxTransferSize [<Int>]
Parameter to set the unit of transfer. Values must be a multiple by 64kb
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-NoRecovery [<Switch>]
Leave the database in a restoring state so that further restore may be made
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-OutputScriptOnly [<Switch>]
If set, the restore will not be performed, but the T-SQL scripts to perform it will be returned
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-PageRestore [<System.Object[]>]
The output from Get-DbaSuspect page containing the suspect pages to be restored.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-RestoreTime [<Datetime>]
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
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-SqlCredential [<Pscredential>]
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.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-SqlInstance [<DbaInstanceParameter>]
The SqlInstance to which the backups should be restored
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-StandbyDirectory [<String>]
A folder path where a standby file should be created to put the recovered databases in a standby mode
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-VerifyOnly [<Switch>]
If set, performs a Verify of the backups rather than a full restore
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-WithReplace [<Switch>]
Indicated that if the database already exists it should be replaced
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
OUTPUTS
NOTES
Tags: Restore, Backup
Author: Stuart Moore (@napalmgram - http://stuart-moore.com)
Website: https://dbatools.io
Copyright: (c) 2018 by dbatools, licensed under MIT
License: MIT https://opensource.org/licenses/MIT
-------------------------- EXAMPLE 1 --------------------------
PS C:\\>$BackupHistory | Invoke-DbaAdvancedRestore -SqlInstance MyInstance
Will restore all the backups in the BackupHistory object according to the transformations it contains
-------------------------- EXAMPLE 2 --------------------------
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
RELATED LINKS
https://dbatools.io/Invoke-DbaAdvancedRestore
SYNOPSIS
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
SYNTAX
Invoke-DbaAdvancedRestore [-BackupHistory] <System.Object[]> [[-SqlInstance] <DbaInstanceParameter>]
[[-SqlCredential] <Pscredential>] [-OutputScriptOnly <Switch>] [-VerifyOnly <Switch>] [[-RestoreTime] <Datetime>]
[[-StandbyDirectory] <String>] [-NoRecovery <Switch>] [[-MaxTransferSize] <Int>] [[-BlockSize] <Int>]
[[-BufferCount] <Int>] [-Continue <Switch>] [[-AzureCredential] <String>] [-WithReplace <Switch>]
[-KeepReplication <Switch>] [-KeepCDC <Switch>] [[-PageRestore] <System.Object[]>] [-EnableException <Switch>]
[<CommonParameters>]
DESCRIPTION
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.
PARAMETERS
-AzureCredential [<String>]
AzureCredential required to connect to blob storage holding the backups
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-BackupHistory [<System.Object[]>]
The BackupHistory object to be restored.
Can be passed in on the pipeline
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-BlockSize [<Int>]
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
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-BufferCount [<Int>]
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
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-Continue [<Switch>]
Indicates that the restore is continuing a restore, so target database must be in Recovering or Standby states
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-EnableException [<Switch>]
Replaces user friendly yellow warnings with bloody red exceptions of doom!
Use this if you want the function to throw terminating errors you want to catch.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-KeepCDC [<Switch>]
Indicates whether CDC information should be restored as part of the database
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-KeepReplication [<Switch>]
Indicates whether replication configuration should be restored as part of the database restore operation
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-MaxTransferSize [<Int>]
Parameter to set the unit of transfer. Values must be a multiple by 64kb
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-NoRecovery [<Switch>]
Leave the database in a restoring state so that further restore may be made
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-OutputScriptOnly [<Switch>]
If set, the restore will not be performed, but the T-SQL scripts to perform it will be returned
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-PageRestore [<System.Object[]>]
The output from Get-DbaSuspect page containing the suspect pages to be restored.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-RestoreTime [<Datetime>]
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
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-SqlCredential [<Pscredential>]
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.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-SqlInstance [<DbaInstanceParameter>]
The SqlInstance to which the backups should be restored
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-StandbyDirectory [<String>]
A folder path where a standby file should be created to put the recovered databases in a standby mode
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-VerifyOnly [<Switch>]
If set, performs a Verify of the backups rather than a full restore
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-WithReplace [<Switch>]
Indicated that if the database already exists it should be replaced
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
OUTPUTS
NOTES
Tags: Restore, Backup
Author: Stuart Moore (@napalmgram - http://stuart-moore.com)
Website: https://dbatools.io
Copyright: (c) 2018 by dbatools, licensed under MIT
License: MIT https://opensource.org/licenses/MIT
-------------------------- EXAMPLE 1 --------------------------
PS C:\\>$BackupHistory | Invoke-DbaAdvancedRestore -SqlInstance MyInstance
Will restore all the backups in the BackupHistory object according to the transformations it contains
-------------------------- EXAMPLE 2 --------------------------
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
RELATED LINKS
https://dbatools.io/Invoke-DbaAdvancedRestore