Perform Automatic Clone Database Refresh with Templates?
SeanPerkins
Posts: 13 New member
in SQL Clone
We have the business requirement to automatically refresh our images/clones at regular intervals.
An example was provided in the SQL Clone documentation to refresh all clone databases to use an updated image:
https://documentation.red-gate.com/clone4/automation/powershell-worked-examples/refresh-all-clone-databases-to-use-an-updated-image
How can this be accomplished for clones that are using a template?
The 'New-SqlClone' cmdlet has a -Template parameter, but the template does not exist in the new image, so the operation fails.
The 'New-SqlCloneTemplate' cmdlet could resolve that issue by creating the template for the new image, but it has no parameter that can accept a 'CloneTemplateResource' object. This prevents the template object from being directly transferred.
The template could potentially be re-created from the original modification scripts/files, however, the 'CloneTemplateResource' object in PowerShell does not appear to have a property containing the modification scripts and/or their original file paths (even though the SQL Clone GUI does show the original filenames on mouse hover). This prevents passing existing scripts from the template object to the 'New-SqlCloneSqlScript' cmdlet (for use with the -Modifications parameter of 'New-SqlCloneTemplate').
The only solution I can think of so far is to manually create templates at image creation (not clone creation), regardless of their use by clones, and then try to match on template name during the refresh. But... this solution brings with it a whole new host of problems too: clones dictate the need for templates and clone/template requirements may not be available at image creation, scripts used in the old image template may not match up with those used in the new image template of the same name and create discrepancies, the clone creation will fail if an expected template is unavailable in the new image, many templates could go unused and create clutter in every new image, and increased manual intervention in the "automatic" clone refresh and image creation processes.
Am I overlooking the proper way to accomplish this task? Feedback would be appreciated. Thanks.
An example was provided in the SQL Clone documentation to refresh all clone databases to use an updated image:
https://documentation.red-gate.com/clone4/automation/powershell-worked-examples/refresh-all-clone-databases-to-use-an-updated-image
How can this be accomplished for clones that are using a template?
The 'New-SqlClone' cmdlet has a -Template parameter, but the template does not exist in the new image, so the operation fails.
The 'New-SqlCloneTemplate' cmdlet could resolve that issue by creating the template for the new image, but it has no parameter that can accept a 'CloneTemplateResource' object. This prevents the template object from being directly transferred.
The template could potentially be re-created from the original modification scripts/files, however, the 'CloneTemplateResource' object in PowerShell does not appear to have a property containing the modification scripts and/or their original file paths (even though the SQL Clone GUI does show the original filenames on mouse hover). This prevents passing existing scripts from the template object to the 'New-SqlCloneSqlScript' cmdlet (for use with the -Modifications parameter of 'New-SqlCloneTemplate').
The only solution I can think of so far is to manually create templates at image creation (not clone creation), regardless of their use by clones, and then try to match on template name during the refresh. But... this solution brings with it a whole new host of problems too: clones dictate the need for templates and clone/template requirements may not be available at image creation, scripts used in the old image template may not match up with those used in the new image template of the same name and create discrepancies, the clone creation will fail if an expected template is unavailable in the new image, many templates could go unused and create clutter in every new image, and increased manual intervention in the "automatic" clone refresh and image creation processes.
Am I overlooking the proper way to accomplish this task? Feedback would be appreciated. Thanks.