0

I am searching for way to create scheduled snapshot creation script. With possibility to set retention days/ count. Maybe someone can share some example or say what are using to create auto snapshots for VM

  • I have using veeam backup&replication free edition without using any automation.. searching way to use any atomation – Edgars Nov 13 '15 at 17:53
1

If you have enought knowledge in shell, this is the command to create snaphot:

vim-cmd vmsvc/snapshot.create $SRC/$VM/$VM.vmx

with :

  • $SRC = datastore path
  • $VM = VM folder name

As the ESXi reset some files each reboot, this is the way to add a script to crontab:

edit /etc/rc.local.d/local.sh (permanent after reboot & launched at each reboot)

#add to crontab a task
echo "01 00 1,15 * * root /vmfs/volumes/datastore1/script/backupVM.sh" >> /var/spool/cron/crontabs/root
#stop crontab process
kill $(cat /var/run/crond.pid)
#start crontab process
crond

Do not forget to set your script as executable

chmod +x /vmfs/volumes/datastore1/script/backupVM.sh

List of Esxi commands

https://pubs.vmware.com/vsphere-50/index.jsp#com.vmware.vcli.ref.doc_50/vcli-right.html

Here is an example of the shell scripting possibilities on ESXi: https://github.com/Fro99666/BASH_froggESXIbackupVM/blob/master/backupVM.sh

This script create backup of VM,tar them, make a copy, and send them backup via FTP. Once finished it send a mail with the log of the process

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.