I know we shouldn't be using snapshots for backup but we kind of need this feature right now to protect a critical server for the next 2 weeks. Is it possible to automate the creation of snapshot at 6AM and 6PM then delete the 2 oldest snapshot at 10PM? The environment is on a free ESXi version so I believe we have to create cron jobs for it in the ESXi Host? Please advise.
Thank you all in advanced!
To "protect" a VM running on free ESXi you do NOT make the system more fragile by adding snapshots !!!
Instead you remove all snapshots - make sure the vmdks are eager-zeroed provisioned and then write down the mapping of the existing fragments.
Store the textfile with the mapping outside of the ESXi.
How to create a textfile with the mapping::
vmkfstools -p 0 name-flat.vmdk > name-flat-mapping.txt
Then copy name-flat-mapping.txt to your admin-host.
This procedure "protects" your vmdk against accidental deletes and VMFS-corruption.
And by the way ... creating cron-jobs in free ESXi is not trivial !
I found this below command in this article but its unfortunately not deleting the oldest snapshot. Can you guys check what could be missing here?
SNAPSHOT_COUNT=`vim-cmd vmsvc/snapshot.get $VM_ID | egrep -- '--\|-CHILD|^\|-ROOT' | wc -l`
vim-cmd vmsvc/snapshot.remove $VM_ID false $(($SNAPSHOT_COUNT-1)) 0