These pages cover SQL Clone Technical Preview 0.2 to 0.3, which is not the latest version. Help for other versions is also available.

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

The installer automatically sets up PowerShell to use the module located at: C:\Program Files (x86)\Red Gate\Instant Clone X.Y.Z\Modules\. Run the PowerShell command-line or ISE as an administrator. Use the cmdlets like this. Finish all invocations with –Verbose to see debug output. 

# Set connection string for use by Instant Clone. Only need to do this the first time
Initialize-InstantCloneConnectionString -ConnectionString "Server=JOHNSMITHTEST\sql2012;Trusted_Connection=True" -Verbose

# Save a snapshot of my WidgetProd database to disk
Save-InstantCloneSnapshot -DatabaseName WidgetProd -SnapshotName WidgetSnp1 -Verbose

# Create a couple of clones from the WidgetSnp1 snapshot
New-InstantCloneClone -NewDatabaseName WidgetClone1 -SnapshotName WidgetSnp1 -Verbose
New-InstantCloneClone -NewDatabaseName WidgetClone2 -SnapshotName WidgetSnp1 -Verbose

# I'm bored with these clones now. Let's drop them
Remove-InstantCloneClone -CloneName WidgetClone1 -Verbose
Remove-InstantCloneClone -CloneName WidgetClone2 -Verbose

# Let's drop that snapshot too
Remove-InstantCloneSnapshot -SnapshotName WidgetSnp1 -Verbose

When you restart your machine, clone databases will be offline until you run the restore cmdlet:
Restore-InstantClone -Verbose

See all the clones and snapshots with the Show-InstantCloneSnapshots/Clones cmdlets
Show-InstantCloneSnapshots -Verbose
Show-InstantCloneClones -Verbose

See all cmdlets available with the Get-Command cmdlet:
Get-Command -Module RedGate.InstantClone.PowerShell

Sharing a snapshot using the PowerShell cmdlets

You may want to create a snapshot on one machine, but clone it on another. To do this, setup the
On the source machine:

  1. Setup your shared folder with the Save-InstantCloneOptions cmdlet:

Save-InstantCloneOptions -SharedSnapshotFolder [\\myServer\SharedSnapshots|\\myServer\SharedSnapshots] -Verbose 

  1. Create a snapshot as usual with the Save-InstantCloneSnapshot cmdlet:

Save-InstantCloneSnapshot -DatabaseName AdventureWorks -SnapshotName AdvSnap -Verbose

  1. Run the Save-InstantCloneSharedSnapshot cmdlet. This will copy your Snapshot into the shared-directory so it can be accessed by others.

Save-InstantCloneSharedSnapshot -SnapshotName AdvSnap -NewSnapshotName AdvSnapShared
A shared-snapshot can listed/deleted/cloned just like any other snapshot.
On the target machine:

  1. Setup your shared folder with the Save-InstantCloneOptions cmdlet:

Save-InstantCloneOptions -SharedSnapshotFolder [\\myServer\SharedSnapshots|\\myServer\SharedSnapshots] -Verbose

  1. (Optional) Run Show-InstantCloneSnapshot cmdlet. AdvSnapShared is listed.

Show-InstantCloneSnapshots -Verbose

  1. Run the New-InstantCloneClone cmdlet to create a new clone from the shared-snapshot.

New-InstantCloneClone -SnapshotName AdvSnapShared -NewDatabaseName AdvClone -Verbose 

  • No labels