Scripts to snap VMs then snap array for vmware

Post Reply
hdtvguy
Posts: 576
Joined: Sun Jul 29, 2012 9:30 am

Scripts to snap VMs then snap array for vmware

Post by hdtvguy »

I use this script to backup up over 700 VMs every night by snapping the VMs then snapping the array. Use at your own risk. It sues password file for the 3par CLI. You point it at a cluster and it will enumerate datastores and then one datastore at a time enumerate VMs and snap them then snap array and finally discard the VM snap.
There is an option to pass a duration on hor long the array snap will last before expiring so the array will do automatic cleanup.

There is an option dsfilter switch that allows you to only target datastores that match the filter. We use this since some datastores like our templates and SRM datastore are presented to all clusters and we do not want them snapped. We are very structured in our naming conventions so the filter works well. As an example we name all our datastores as aaaa:eee:nnnn where aaaa is the array name, eee is the cluster name and nnn is the datastore name. The script requires that you follow that format as it will parse the DS name and look at the last section and will expect there to be a volume on the array that contains that in its name. If you look at the function SnapArray you can modify that to fit your own naming enumeration.

We snap every datastore 7 days a week and retain the array snaps for 14 days. This process has been a huge success because recovery times are usually in <15min. Most traditional backup products will take forever to recover a VM. True this mans the recovery is a manual process and requires storage people to be involved, but my team is viirtualization and storage so there is no politics involved.

The recovery process we use is to pick the snap needed, preset a r/w copy to the cluster then browse the datastore of that snap and add the VM to inventory, power it up and then storage migrate it to the proper volume. When complete, remove the presented snap and clean up.

Script requires Powershell and PowerCLI as well as 3par CLI
Attachments
vmsnaps-ds.txt
(8.83 KiB) Downloaded 3522 times
Post Reply