Powershell scripts to move VMs to Write-Through before storage appliance snapshot starts and move VMs back to original caching policy after snapshot completes

You are here:
  • Main
  • Configuration
  • Powershell scripts to move VMs to Write-Through before storage appliance snapshot starts and move VMs back to original caching policy after snapshot completes
< All Topics

Download the scripts from below link.

Scripts that move VMs to Write-Through mode before controller snapshot is taken and revert VMs back to original caching policy after snapshot completes

These scripts are only required if the below condition is true:

[You use SAN controller snapshots to backup LUNs, without using any VM based backup software like Veeam, Commvault etc.] AND [One or more VMs are in Write-Back caching mode]

Reason for these scripts.

In caching mode ‘Write Back 1 Replica’, VirtuCache cache writes to in-host SSD/RAM. All writes are written to local cache media. Every few milliseconds we have a background job that syncs the writes in the local cache media to the backend appliance. Now at any point in time the local cache media will have writes that are not on the backend SAN appliance (dirty writes). Now if a storage controller snapshot is initiated from the storage appliance management application/CLI, the snapshot won’t capture the latest state of the LUN. For the SAN controller snapshot to capture the most recent consistent state of the LUN, VirtuCache needs to flush all the writes from local cache media to the LUN before a SAN controller snapshot is taken.

Steps to deploy scripts

These scripts flush writes from host cache to SAN appliance, by moving all the VMs to Write-Through mode, and after the SAN snapshot is taken, move all the VMs back to their original caching policy.

The first script is run before the SAN snapshot is created. It moves the VMs to Write-Through mode, which flushes all writes in cache to the LUN. The second script is run after the backup job ends, and it moves the VMs back to the original caching policy.

First make sure you have the two *.bat files and the two *.ps1 files from the link above.

These scripts invoke the VirtuCache ‘quiesce’ feature that allows VMs to be transitioned to write-though policy and for those VMs to be transitioned back to their configured write-back policy after the SAN snapshot process is complete.

– before_backup.bat (batch file – It calls the before_backup.ps1 script.)

– before_backup.ps1 (Powershell script containing the pre-backup processing logic)

– after_backup.bat    (batch file – It calls the after_backup.ps1 script.)

– after_backup.ps1    (Powershell script containing the post-backup processing)

Instructions:

1) Transfer these scripts to a Windows VM that has https (or http) connectivity to VirtuCache manager VM IP addresses. Place the scripts in a folder, say C:VirtuCache

2) Edit the before_backup.ps1 script as follows:

– specify the IP address of the vCenter server (in ‘serverip’ variable)

– specify the login credentials for the vCenter (in ‘username’ and ‘password’ variables). vCenter credentials can be read-only.

– specify the IP address of the VirtuCache manager appliance and the name of the Datastores on which the VMs reside in the lines below. Add one UploadValues line for each datastore. Also even though the quiesce and unquiesce functions are run at the Datastore level, these operations are performed at the VM level.

Spaces, and non-alphanumeric characters are allowed in Datastore names for the script syntax below.

[void] $wc.UploadValues(‘https://ip-address-of-virtucache-mgr-appliance/datastore/name-of-datastore/quiesce’, $p)

e.g.
[void] $wc.UploadValues(‘https://10.0.0.73/datastore/erp-datastore/quiesce‘, $p)
[void] $wc.UploadValues(‘https://10.0.0.73/datastore/equallogic-datastore1/quiesce‘, $p)

3) Similarly configure the settings in after_backup.ps1 script as well

4) Now run the before_backup.bat file before the SAN snapshot process runs, and after_backup.bat after the SAN snapshot process completes.

Below is an example of the before_backup.ps1 and after_backup.ps1 scripts

In the scripts below 10.72.6.100 is vcenter IP with vcenter read-only userid and password. 10.72.6.132 is VirtuCache Manager VM IP

before_backup.ps1 file

[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}

$p = New-Object System.Collections.Specialized.NameValueCollection

$p.Add(‘username’,’[email protected]’)

$p.Add(‘password’,’vidanlogin$%^&’)

$p.Add(‘serverip’,’10.72.6.100′)

$wc = New-Object Net.WebClient

[void] $wc.UploadValues(‘https://10.72.6.132/datastore/equallogic volume 1/quiesce’, $p)

[void] $wc.UploadValues(‘https:// 10.72.6.132/datastore/equallogic volume 2/quiesce’, $p)

[void] $wc.UploadValues(‘https:// 10.72.6.132/datastore/equallogic volume 3/quiesce’, $p)

[void] $wc.UploadValues(‘https:// 10.72.6.132/datastore/equallogic volume 4/quiesce’, $p)

[void] $wc.UploadValues(‘https:// 10.72.6.132/datastore/equallogic volume 5/quiesce’, $p)

[void] $wc.UploadValues(‘https:// 10.72.6.132/datastore/equallogic volume 6/quiesce’, $p)

Start-Sleep 300

 

after_backup.ps1 file

[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}

$p = New-Object System.Collections.Specialized.NameValueCollection

$p.Add(‘username’, ‘[email protected]’)

$p.Add(‘password’, ‘vidanlogin$%^&’)

$p.Add(‘serverip’, ‘10.72.6.100’)

$wc = New-Object Net.WebClient

[void] $wc.UploadValues(‘https://10.72.6.132/datastore/equallogic volume 1/unquiesce’, $p)

[void] $wc.UploadValues(‘https://10.72.6.132/datastore/equallogic volume 2/unquiesce’, $p)

[void] $wc.UploadValues(‘https://10.72.6.132/datastore/equallogic volume 3/unquiesce’, $p)

[void] $wc.UploadValues(‘https://10.72.6.132/datastore/equallogic volume 4/unquiesce’, $p)

[void] $wc.UploadValues(‘https://10.72.6.132/datastore/equallogic volume 5/unquiesce’, $p)

[void] $wc.UploadValues(‘https://10.72.6.132/datastore/equallogic volume 6/unquiesce’, $p)

 

Table of Contents
Download Trial Contact Us