API, English, ERA, Technology

REST API / PowerShell ERA Clone Refresh

A customer is using the power of ERA to have the most efficient way of cloning and refreshing databases fast and lean. The power of ERA lies that no knowledge is required from the underlying engine to execute these repetitive tasks.

Which is also true in this use case.

Customer wanted a PowerShell script to use inside their SQL statement so the ERA engine takes care of the refresh. The script below takes care of this task. It has 2 modes, Create / Select. Create will create a new snapshot on the spot, the snapshot will be used to refresh the clone with. Or a select mode, a very simple select script that finds the last snapshot after a certain day in the week, meaning it allows to select a snapshot created in the last 7 days.

It uses a PSM1 module for functions and a ps1 file for execution.
please edit the ps1 file variables in the top.

$mode               = "Select"                  ### Create or Select, Create a snapshot on execution and wait, or select last snap of day after hour.
$dayofweek          = "Today"                   ### Not required if set to create, find first snapshot after day / hour
$AfterHour          = 4                         ### Hour of day that snap needs to be younger then 24 h notation UTC
$SourceDatabaseName = "WideWorldImporters"      ### Source Database name
$ClonedDatabaseName = "WideWorldImportersDEV"   ### Target Database aka Clone to be refreshed.
$ERAAdmin           = "admin"                   ### Should always be admin (RBAC release is pending ERA 1.1)
$ERAPass            = "xxxx"                    ### Best is to change this to a secure string. Or some Service account vault API method
$ERAIP              = "xxxx"                    ### IP Address of the ERA Instance.
$ERAPort            = "8443"                    ### 8443 or 443 depending on firewall rules and ERA version of your infrastructure.
$ScriptInstallDir   = "C:\temp"                 ### Path to load the module from. Functions can also be pasted here.
$debug              = 1                         ### Displays Variables as the are loaded in the object

No parameters have been set to run these from the shell. This is just an initial mock-up. Let me know if you wish any modifications:


Mode Select Snapshot:

Mode Create Snapshot

Leave a Reply