Author | Simone Bizzotto (@niphold) |
Availability | Windows, Linux, macOS |
Want to see the source code for this command? Check out Restore-DbaDbSnapshot on GitHub.
Want to see the Bill Of Health for this command? Check out Restore-DbaDbSnapshot.
Restores databases from snapshots
Restores the database from the snapshot, discarding every modification made to the database
NB: Restoring to a snapshot will result in every other snapshot of the same database to be dropped
It also fixes some long-standing bugs in SQL Server when restoring from snapshots
Restore-DbaDbSnapshot
[[-SqlInstance] <DbaInstanceParameter[]>]
[[-SqlCredential] <PSCredential>]
[[-Database] <Object[]>]
[[-ExcludeDatabase] <Object[]>]
[[-Snapshot] <Object[]>]
[[-InputObject] <Database[]>]
[-Force]
[-EnableException]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
PS C:\> Restore-DbaDbSnapshot -SqlInstance sql2014 -Database HR, Accounting
Restores HR and Accounting databases using the latest snapshot available
PS C:\> Restore-DbaDbSnapshot -SqlInstance sql2014 -Database HR -Force
Restores HR database from latest snapshot and kills any active connections in the database on sql2014.
PS C:\> Get-DbaDbSnapshot -SqlInstance sql2016 -Database HR | Restore-DbaDbSnapshot -Force
Restores HR database from latest snapshot and kills any active connections in the database on sql2016.
PS C:\> Get-DbaDbSnapshot -SqlInstance sql2016 | Out-GridView -PassThru | Restore-DbaDbSnapshot
Allows the selection of snapshots on sql2016 to restore
PS C:\> Restore-DbaDbSnapshot -SqlInstance sql2014 -Snapshot HR_snap_20161201, Accounting_snap_20161101
Restores databases from snapshots named HR_snap_20161201 and Accounting_snap_20161101
The target SQL Server instance or instances
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 |
Restores from the last snapshot databases with this names only. You can pass either Databases or Snapshots
Alias | |
Required | False |
Pipeline | false |
Default Value |
The database(s) to exclude - this list is auto-populated from the server
Alias | |
Required | False |
Pipeline | false |
Default Value |
Restores databases from snapshots with this names only. You can pass either Databases or Snapshots
Alias | |
Required | False |
Pipeline | false |
Default Value |
Allows piping from other Snapshot commands
Alias | |
Required | False |
Pipeline | true (ByValue) |
Default Value |
If restoring from a snapshot involves dropping any other snapshot, you need to explicitly
use -Force to let this command delete the ones not involved in the restore process.
Also, -Force will forcibly kill all running queries that prevent the restore process.
Alias | |
Required | False |
Pipeline | false |
Default Value | False |
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 command were to run
Alias | wi |
Required | False |
Pipeline | false |
Default Value |
Prompts for confirmation of every step.
Alias | cf |
Required | False |
Pipeline | false |
Default Value |