VMware Cloud Community
durgabaps
Contributor
Contributor

Scheduling Snapsots for Vm's residing on an iSCSI datastore?

Hi Team,

Please let me know the below following:

1) Is it possible to schedule snapsots for vm's which reside on iSCSI datastore?

2) What should be the minimum free space available for the snapshots?

3) Is there a retenetion period which can be set for those snapsots?

Thanks,

0 Kudos
3 Replies
NuggetGTR
VMware Employee
VMware Employee

1) Is it possible to schedule snapsots for vm's which reside on iSCSI datastore?

well to my knowledge you cant schedule a snapshot through vCenter, but its quiet easy to do this via powercli and use windows task scheduler to run it when you need it run.

2) What should be the minimum free space available for the snapshots?

Depends I enforce a 10% min free space on data stores across the board, but thats my policy, it really depends on what your going to be doing? you install 1GB of patches your going to be looking at a snapshot file as big if not bigger than that. you have to use your judgement.

3) Is there a retenetion period which can be set for those snapshots?

Not through vcenter there isn't, Again this is something you have to manage on a per snapshot basis, snapshots are NOT backups and should not be used as such, should be used over small time frames. snapshot -> install patches -> test -> delete/revert back snapshot. Again a policy of mine is 5 days it was 3 but i was feeling lenient, I have a powershell script that will commit snapshots older than 5 days this runs every night accross all vms, so i dont need to worry about patching guys making a snapshot and 6 months later its still running the snapshot and its crashed and corrupted.

________________________________________ Blog: http://virtualiseme.net.au VCDX #201 Author of Mastering vRealize Operations Manager
durgabaps
Contributor
Contributor

thanks a lot..

Please share the script if it is fine with you for automating the deletion of the snapshots.

Thanks,

0 Kudos
NuggetGTR
VMware Employee
VMware Employee

Yeah sure no worries

Function write-log([String]$info) {
	$info >> $logname

}

$today = get-date
$logdate = get-date -format yyyyMMdd
$threedays = (get-date).adddays(-5)
$filename = $logdate + ".log"
$logname = "e:\vmwaresupport\logs\autosnap\$filename"
$exists = test-path $logname
$freepass = get-content e:\vmwaresupport\logs\autosnap\freepass.txt
if ($exists -eq $false){
new-item e:\vmwaresupport\logs\autosnap\$filename -type file
}

$credentials = Get-VICredentialStoreItem -File "E:\VMwareSupport\Credentials\Credfile.xml"
ForEach ($cred in $credentials) 
{
	connect-viserver -Server $cred.Host -User $cred.User -Password $cred.Password
	$vcservername = $cred.host
	write-log "Connected to $vcservername"
	$clusters = get-cluster | Get-View | Sort Name
	ForEach ($cluster in $clusters) 
	{
		$clustername = $cluster.Name
		$allvm = get-cluster $clusterName | get-vm
		write-host "Checking: $clusterName"
		write-log "Currently Checking: $clusterName"
		



		foreach ($snap in ($allvm | get-snapshot)) 
		{
	
			$row = "" | select vmname, pstate, created
			$row.vmname = $snap.vm.name
			$row.pstate = $snap.powerstate
			$row.created = $snap.Created
			$report += $row
			write-host $row
			write-log $row
			$testing = 1

			foreach ($machine in $freepass)
			{
				if ($row.vmname -eq $machine)
					{
					$testing = 2
					}
			}

			if($snap.Created -gt $threedays)
			{
				write-host "Wont Delete" 
				write-log "Will not Delete"
			} 
			else
			{
				If ($testing -eq 2)
				{
					write-host "Wont Delete, machine currently has a free pass and is to be kept" 
					write-log "Will not Delete (machine currently has a free pass and is to be kept)"
				}
				else
				{
					write-host "will delete"
					write-log "Deleting"
					Remove-Snapshot -Snapshot $snap -RemoveChildren -confirm:$false
				}

			} 
		}
	}
	clear-variable clusters
	clear-variable cluster
	write-log "cleared cluster"
	write-log "Disconnecting from $vcservername"
	
	Disconnect-VIServer -Confirm:$False
}

I use a cred file to loop through all my virtual center boxes, also have a freepass.txt file which is basically an exclusion in case there is some business reason or case put forward as to why a snapshot needs longer than the 5 days given.

________________________________________ Blog: http://virtualiseme.net.au VCDX #201 Author of Mastering vRealize Operations Manager
0 Kudos