SQL Clone 3

Run a Data Masker masking set during image creation

SQL Clone version 2.5.0 can run Data Masker v6 masking sets on image databases while they are being created. This can be combined with running SQL scripts on the same image.

Clone Agent will attach the image files directly to the SQL Server instance being used to create it (either the instance it came from for an image from SQL Server, or the temporary instance for an image from a backup file).

# Script to create a new SQL Clone data image and run a Data Masker masking set on it

Connect-SqlClone -ServerUrl 'http://sql-clone.example.com:14145'
$SqlServerInstance = Get-SqlCloneSqlServerInstance -MachineName WIN201601 -InstanceName SQL2014
$ImageDestination = Get-SqlCloneImageLocation -Path '\\red-gate\data-images'
 
$MaskingSet= New-SqlCloneMask -Path \\red-gate\masking-sets\clean-pii-data.dmsmaskset

$ImageOperation = New-SqlCloneImage -Name "AdventureWorks-$(Get-Date -Format yyyyMMddHHmmss)-Cleansed" `
    -SqlServerInstance $SqlServerInstance `
    -DatabaseName 'AdventureWorks' `
    -Destination $ImageDestination `
    -Modifications $MaskingSet
 
Wait-SqlCloneOperation -Operation $ImageOperation

You can specify any number of modifications in any order:

# Script to create a new SQL Clone data image with both a Data Masker masking set and post-image T-SQL

Connect-SqlClone -ServerUrl 'http://sql-clone.example.com:14145'
$SqlServerInstance = Get-SqlCloneSqlServerInstance -MachineName WIN201601 -InstanceName SQL2014
$ImageDestination = Get-SqlCloneImageLocation -Path '\\red-gate\data-images'

$MaskingSet= New-SqlCloneMask -Path \\red-gate\masking-sets\clean-pii-data.dmsmaskset
$PermissionsScript = New-SqlCloneSqlScript -Path \\red-gate\data-scripts\change-permissions.sql

$ImageOperation = New-SqlCloneImage -Name "AdventureWorks-$(Get-Date -Format yyyyMMddHHmmss)-CleansedAndWithPermissionsChanges" `
    -SqlServerInstance $SqlServerInstance `
    -DatabaseName 'AdventureWorks' `
    -Destination $ImageDestination `
	-Modifications @($MaskingSet, $PermissionsScript)
 
Wait-SqlCloneOperation -Operation $ImageOperation

Didn't find what you were looking for?