Author | Simone Bizzotto (@niphold) |
Availability | Windows, Linux, macOS |
Want to see the source code for this command? Check out New-DbaDbSnapshot on GitHub.
Want to see the Bill Of Health for this command? Check out New-DbaDbSnapshot.
Creates database snapshots
Creates database snapshots without hassles
New-DbaDbSnapshot
[[-SqlInstance] <DbaInstanceParameter[]>]
[[-SqlCredential] <PSCredential>]
[[-Database] <Object[]>]
[[-ExcludeDatabase] <Object[]>]
[-AllDatabases]
[[-Name] <String>]
[[-NameSuffix] <String>]
[[-Path] <String>]
[-Force]
[[-InputObject] <Database[]>]
[-EnableException]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
PS C:\> New-DbaDbSnapshot -SqlInstance sqlserver2014a -Database HR, Accounting
Creates snapshot for HR and Accounting, returning a custom object displaying Server, Database, DatabaseCreated, SnapshotOf, SizeMB, DatabaseCreated, PrimaryFilePath, Status, Notes
PS C:\> New-DbaDbSnapshot -SqlInstance sqlserver2014a -Database HR -Name HR_snap
Creates snapshot named "HR_snap" for HR
PS C:\> New-DbaDbSnapshot -SqlInstance sqlserver2014a -Database HR -NameSuffix 'fool_{0}_snap'
Creates snapshot named "fool_HR_snap" for HR
PS C:\> New-DbaDbSnapshot -SqlInstance sqlserver2014a -Database HR, Accounting -Path F:\snapshotpath
Creates snapshots for HR and Accounting databases, storing files under the F:\snapshotpath\ dir
PS C:\> Get-DbaDatabase -SqlInstance sql2016 -Database df | New-DbaDbSnapshot
Creates a snapshot for the database df on sql2016
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 |
The database(s) to process - this list is auto-populated from the server. If unspecified, all databases will be processed.
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 |
Creates snapshot for all eligible databases
Alias | |
Required | False |
Pipeline | false |
Default Value | False |
The specific snapshot name you want to create. Works only if you target a single database. If you need to create multiple snapshot,
you must use the NameSuffix parameter
Alias | |
Required | False |
Pipeline | false |
Default Value |
When you pass a simple string, it'll be appended to use it to build the name of the snapshot. By default snapshots are created with yyyyMMdd_HHmmss suffix
You can also pass a standard placeholder, in which case it'll be interpolated (e.g. '{0}' gets replaced with the database name)
Alias | |
Required | False |
Pipeline | false |
Default Value |
Snapshot files will be created here (by default the file structure will be created in the same folder as the base db)
Alias | |
Required | False |
Pipeline | false |
Default Value |
Databases with Filestream FG can be snapshotted, but the Filestream FG is marked offline
in the snapshot. To create a "partial" snapshot, you need to pass -Force explicitly
NB: You can't then restore the Database from the newly-created snapshot.
For details, check https://msdn.microsoft.com/en-us/library/bb895334.aspx
Alias | |
Required | False |
Pipeline | false |
Default Value | False |
Allows Piping from Get-DbaDatabase
Alias | |
Required | False |
Pipeline | true (ByValue) |
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 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 |