clone-backup
Use this cmdlet to clone databases from an existing backup or archive using the SnapManager SQL Server PowerShell command-line interface. You can also use this cmdlet to add (by cloning) a database to an Availability Group.
clone-backup [-Server <String>] [-UserName <String>] [-Password <String>] [-ServerInstance <String[]>] -Database <String[]> [-Backup <String>] [-RestoreLastBackup <Int32>] [-TransLogsToApply <Int32[]>] [-ForceRestore [<Boolean>]] [-ClusterAware] [-TargetDatabase <String[]>] [-TargetServerInstance <String[]>] [-TargetServerMountPointDir <String>] [-PointInTime <String[]>] [-SnapInfoDirectory <String>] [-MarkName <String[]>] [-MarkTime <String[]>] [-RestoreBeforeMark [<Boolean>]] [-RecoverDatabase <Boolean[]>] [-StandbyPath <String>] [-apicontext] [-RestoreArchivedBackup] [-SnapVaultSecondary] [-CloneOnMirrorDestination] [-ChangeClonePath] [-CloneMirrorDestVolumes <String[]>] [-PreCommand] [-PreCommandPath <String>] [-PreCommandArguments <String>] [-PreCommandHost <String>] [-PreCommandErrors <EnumHandleCmdError[]>] [-PostCommand] [-PostCommandPath <String>] [-PostCommandArguments <String>] [-PostCommandHost <String>] [-PostCommandErrors <EnumHandleCmdError[]>] [-AvailabilityGroup] [-IgnoreRepLogs] [-WhatIf] [-Confirm] [<CommonParameters>]
You can use this cmdlet to clone a live database or a database that is already backed up in a backup set. This cmdlet restores the database from the existing backup set, to clone the database to an alternate temporary writable LUN location, or to an Availability Group for further use.
You can also implement these options with the SnapManager user interface.
-Server <String> - Short Form: -svr
This parameter denotes the name of the host SQL server on which the SQL server instances reside. SnapManager takes the local computer name as the default server name.
Using this parameter, you can also specify a particular SQL server instance. The following examples illustrate the usage:
-svr win-225-161
-svr sql1
-UserName <String> - Short Form: -usr
This parameter denotes the SQL Server account name. If the login name is not specified, SnapManager uses Windows NT Authentication.
-Password <String> - Short Form: -pwd
This parameter is the SQL Server account password. SnapManager ignores this parameter if the parameter -UserName is not specified.
-ServerInstance <String[]> - Short Form: -inst
This parameter specifies the SQL Server instance where the database is backed up originally. SnapManager takes the local computer name as the default server instance.
If multiple databases reside on the same LUN but are owned by different SQL server instances when you backed them up originally, use the following format:
-Inst "SQLServerInstance1","SQLServerInstance2"
The first database specified in the -Database parameter refers the first server instance in the -ServerInstance parameter, the second database in the -Database parameter refers to the second server instance in the -ServerInstance parameter and so on.
-Database <String[]> - Short Form: -d
Use this option to specify the databases that need to be cloned. Use a comma-separated list of strings:
-d Database 1, Database 2, Database 3, Database 4,....
Multiple database names should be specified only if those databases share a single LUN or multiple LUNs together. For a multiple database restore, all the selected databases should be present in the selected Snapshot copy.
You cannot restore a database with a new name if you specify multiple databases. If you want to restore with a new name, restore those databases one by one. In case of restore to alternate location, specify only one database name.
-Backup <String> - Short Form: -bkup
Use this option to specify the name of the backup set. This is a mandatory parameter. The following example illustrates the usage:
-bkup sqlsnap__SYMNASQLDEV170_04-11-2007_15.22.27
-RestoreLastBackup <Int32> - Short Form: -lastBkup
Use this parameter to restore backups without specifying the name. If you try to use the Backup and RestoreLastBackup parameters together, SnapManager ignores the RestoreLastBackup parameter and uses the backup parameter during restore operation. A typical usage example of the restorelastbackup parameter is as follows:
restore-backup -restorelastbackup 1 -backup <backup name>
-TransLogsToApply <Int32[]> - Short Form: -translogs
This parameter specifies the list of transactions logs that need to be applied. SnapManager applies all transaction logs of the databases specified in the -Database parameter by default. You can specify the number of transaction logs to be applied for every database mentioned in the -Database parameter. The list of number of transaction logs that have to applied has to be listed in the same sequence as the databases listed in the -Database parameter. For example,
restore-backup -svr MACHINE1\INST1 -database db1,db2 -TransLogsToApply 3,7
-ForceRestore [<Boolean>] - Short Form: -force
Use this parameter to force the restore of a database based on its state. SnapManager sets its value to "true" by default.
-ClusterAware - Short Form: -cl
Use this parameter to specify that the cmdlet runs solely on the active node in a cluster environment.
-TargetDatabase <String[]> - Short Form: -tgDb
Use this parameter to restore a database with a new name. The following example illustrates the usage:
-tgDb "NewDatabaseName1"," NewDatabaseName2"," NewDatabaseName3"
The parameter defines the new database name to which the original database is restored. The old database name is defined at the same position in the -Database parameter.
If no new database name is given, the database is restored to the original database name the database had during backup. If this original name already exists, the name is modified to: originalDbName__clone, or originalDbName__mount.
-TargetServerInstance <String[]> - Short Form: -tgInst
This parameter specifies the name of the new SQL server if you want to restore the database to a new SQL Server. SnapManager takes the source SQL server instance as the default.
-TargetServerMountPointDir <String> - Short Form: -tgmpdir
Use this parameter to specify the mount point path or directory of the target server instance in which the backups are cloned or mounted.
-PointInTime <String[]> - Short Form: -pit
Use this switch to restore databases until a specific point in time. The format for the point-in-time string is yyyy-mm-ddThh:mm:ss, with time specified in a 24-hour format.
In case of multiple databases you should specify the point-in-time values for every database separated by a comma. The number of values after the parameter name should equal the number of databases selected. The first value will be applied to the first database specified after the -Database parameter, the second value to the second database, and so on. The following example illustrates the usage:
-pit 2008-10-22T11:50:00, 2008-11-25T22:50:00
-SnapInfoDirectory <String> - Short Form: -snapinfo
Use this parameter to specify the SnapInfo directory path of the archived backup set.
-MarkName <String[]> - Short Form: -mark
This parameter indicates the marked transaction at which to stop the transaction log recovery.
-MarkTime <String[]> - Short Form: -mktm
This parameter specifies a unique timestamp to guarantee the uniqueness of the input restored mark.
-RestoreBeforeMark [<Boolean>] - Short Form: -beforemk
This true or false value indicates whether the specified marked transaction log should be included in the restore.
-RecoverDatabase <Boolean[]> - Short Form: -recoverdb
This parameter indicates whether the database fully recovered or left in a partially recovered state after the cmdlet finishes, to facilitate future SQL transaction log restores. This is an array of booleans, so it must match the same number of elements of the -database array. If the it does not match the number of elements of the -database array, an error is given. This defaults to $true for all databases unless the -standbyPath is given, in which case it defaults to $false for all databases.
-StandbyPath <String> - Short Form: -standby
This parameter indicates the path to the standby recovery file where incomplete transactions are stored after restoring a full database and its transaction logs. There is no default if you specify this parameter. The path must be to the standby directory if more than one database shares a LUN. If the database is on a dedicated LUN, then it must be a specific file. If the -standbypath parameter is given, the -RecoveryDatabase given must be -RecoverDatabase $False, otherwise it defaults to $false for all databases if no _RecoverDatabase parameter is specified.
-apicontext - Short form: none
Use this parameter when calling the cmdlet as an API call.
-RestoreArchivedBackup - Short Form: -rstarchbkup
Use this parameter to specify using remote backup to clone the database.
-SnapVaultSecondary - Short Form: -vaultsec
This optional parameter identifies the backup vault from which you want to clone a database. If you do not specify this parameter, SnapManager chooses one of the backup vaults. You use this parameter in conjunction with the -RestoreArchivedBackup parameter. If you specify this parameter with the -AvailabilityGroup parameter, then the Availability Group databases must be spread across the same volumes. Otherwise, do not specify this parameter and SnapManager will choose one of the backup vaults. This parameter applies to clustered Data ONTAP only.
The syntax for this parameter is as follows:
-SnapVaultSecondary n, Vserver:volume
Where n is the number of Vserver:volume pairs.
Example: -SnapVaultSecondary 3, Vserver1:volume1, Vserver2:volume2, Vserver3:volume3
-CloneOnMirrorDestination - Short Form: -cloneonmir
This parameter indicates to clone a database based on the Snapshot copy on the SnapMirror destination volume. Ensure that the SnapMirror relationship exists and SnapMirror was updated when using this option.
-ChangeClonePath (Boolean Parameter) - Short Form: -chgpath
Use this parameter to change clone database paths based on the new database clone name.
-CloneMirrorDestVolumes <String[]> - Short Form: -clonemir
Use this parameter to specify cloning using the Snapshot copy on the SnapMirror destination volume.
-PreCommand <String> - Short Form: -precmd
This parameter indicates to run a command before the current operation.
-PreCommandPath <String> - Short Form: -precmdpath
This parameter specifies the operating system path to the command to be run before the SnapManager operation starts.
-PreCommandArguments <String> - Short Form: -precmdargs
This parameter contains a list of strings of SnapManager operation-specific information or user-defined arguments to be passed to the program or script. The default is to pass no parameters to the script. If the parameter contains white spaces (tabs or spaces) you need to enclose it in double quotes. This parameter is processed only if the parameters -PreCommand and -PreCommandPath are specified.
-PreCommandHost <String> - Short Form: -precmdhost
This parameter specifies the host machine name on which the command is run before the operation starts. The default is to run on the current machine. This parameter is considered only if the parameters -PreCommand and -PreCommandPath are specified.
-PreCommandErrors <EnumHandleCmdError[]> - Short Form: -precmnderrors
This parameter specifies how to handle errors on the pre-command. The ContinueOnError value (the default) indicates that the SnapManager operation executes even if an error is detected during the pre-command launch. The StopOnPreCmdError value indicates that if a pre-command script gets an error, the remaining SMSQL operation is not attempted. This parameter is considered only if the parameters -PreCommand and -PreCommandPath are specified.
-PostCommand - Short Form: -postcmd
This parameter indicates to run a command after the current operation is complete.
-PostCommandPath <String> - Short Form: -postcmdpath
Use this parameter to specify the operating system path to the command to be run after the SnapManager operation starts.
-PostCommandArguments <String> - Short Form: -postcmdargs
This parameter contains a list of strings of SnapManager operation-specific information or user-defined arguments to be passed to the program or script. The default is to pass no parameters to the script. If the parameter contains white spaces (tabs or spaces) you enclose it in double quotes. This parameter is processed only if the parameters -PostCommand and -PostCommandPath are specified.
-PostCommandHost <String> - Short Form: -postcmdhost
This parameter specifies the host machine name on which the command is run after the operation is complete. The default is to run on the current machine. This parameter is considered only if the parameters -PostCommand and -PostCommandPath are specified.
-PostCommandErrors <EnumHandleCmdError[]> - Short Form: -postcmderrors
This parameter specifies how to handle SMSQL operation errors on the post-command run. The ContinueOnError value (the default) indicates that the SMSQL operation executes even if an error is detected during the post-command launch. The StopOnPostCmdError value indicates that if a post-command script gets an error, the remaining SMSQL operation is not attempted. This parameter is considered only if the parameters -PostCommand and -PostCommandPath are specified.
-AvailabilityGroup <String> - Short Form: -ag
Use this parameter to reseed databases belonging to the given Availability group.
-IgnoreRepLogs: - Short Form: -nosharelogs
Use this parameter to ignore the transaction logbackups from SnapManager Repository Share.
-WhatIf - Short form: -wi
This parameter gives you a preview of an operation.
-Confirm - Short form: -cf
This parameter prompts you for confirmation before the actual operation starts.
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, WarningVariable, OutBuffer and OutVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
Example 1: clone-backup -Server win-225-165 -Database DB2 -Inst win-225-165 -Backup sqlsnap__win-225-165_09-06-2008_13.44.51
This command creates a clone of the specified backup.
Example 2: clone-backup -Server win-225-165 -Database DB2 -Inst win-225-165 -RestoreLastBackup 0
This command restores the most recent clone that was created.
Example 3: clone-backup -Server win-225-165 -Inst win-225-165 -AvailabilityGroup Ag1 -RestoreLastBackup 0
This command restores the most recent clone of the Availability Group that was created.