The installer automatically sets up PowerShell to use the InstantClone PowerShell module (located at: C:\Program Files (x86)\Red Gate\Instant Clone X.Y.Z\Redgate.InstantClone.PowerShell) 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
Save-InstantCloneOptions -SourceConnectionString "Server=JOHNSMITHTEST\sql2012;Trusted_Connection=True" -TargetConnectionString "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
Snapshots and clones are stored by default in C:\Users\YourUser\Documents\Red Gate Instant Clone. If you want to change this, use the Save-InstantCloneOptions cmdlet:
Save-InstantCloneOptions -SnapshotFolder D:\IC\Snapshots -Verbose
Save-InstantCloneOptions -CloneFolder D:\IC\Clones -Verbose
You may want to create a snapshot on one machine and use it on another. For instance, your colleagues might want to use your snapshots, or you might want to create a snapshot on one SQL Server and clone it on another.
Snapshots are, by default, local. Their metadata is stored locally, and they are only cloneable on your machine. You can create a Shared Snapshot which is stored in your Shared Snapshot Folder. This snapshot and can be used on any machine.
To use shared snapshots, each computer should have it's SharedSnapshotsFolder set to a common location e.g. \\john-pc\sharedsnapshots. When you take a snapshot, use the -PutInSharedFolder parameter. The snapshots will then be created in \\john-pc\sharedsnapshots. Then, on any machine, simply create a clone with that name.
On machine 1:
Save-InstantCloneOptions -SharedSnapshotFolder \\john-pc\SharedSnapshots -Verbose
Save-InstantCloneSnapshot -DatabaseName AdventureWorks2012 -SnapshotName aworks_shared -Verbose -PutInSharedFolder
On machine 2:
Save-InstantCloneOptions -SharedSnapshotFolder \\john-pc\SharedSnapshots
New-InstantCloneClone -NewDatabaseName awc1_shared -SnapshotName aworks_shared -Verbose
You may want to create a snapshot on one machine, but clone it on another. To do this:
Save-InstantCloneOptions -SharedSnapshotFolder [\\myServer\SharedSnapshots|\\myServer\SharedSnapshots] -Verbose
Save-InstantCloneSnapshot -DatabaseName AdventureWorks -SnapshotName AdvSnap -Verbose
Save-InstantCloneSharedSnapshot -SnapshotName AdvSnap -NewSnapshotName AdvSnapShared
To delete a shared-snapshot, delete the relevant GUID-named directory.
On the target machine:
Save-InstantCloneOptions -SharedSnapshotFolder [\\myServer\SharedSnapshots|\\myServer\SharedSnapshots] -Verbose
Show-InstantCloneSnapshots -Verbose
New-InstantCloneClone -SnapshotName AdvSnapShared -NewDatabaseName AdvClone -Verbose