I use VMware’s ESXi in my home lab environment. If you’re a technologist that is always messing with operating systems and applications, it is really the only way to go. But along with running any systems comes maintaining good backups!
There are numerous VMware backup products on the market. The problem is they all cost money. For me and other people who just play with this stuff for fun, that is not desirable. At all.
I created a little script that uses only the built in capabilities of a standalone ESXi host and SSH. The features are:
- Uses only bash, SSH, and SCP
- Takes a list of VMs in a config file (not that pretty to do unfortunately – let me know if you have a better way to do it in bash!)
- Can be run via cron
- Backs up both powered off AND running VMs. If the VM is running, a snapshot is created to do the backup and removed on completion
- An email status is sent when backup is complete
I recommend coupling this script with a backup destination on a volume using deduplication to save space. If your environment is like mine, the VMs change very little each backup period, so the deduplication allows a full backup every time without wasting huge amounts of space.
The script is available on my Bitbucket here. If you have any suggestions to improve the script, do let me know. Or even better – fork it and submit a pull request!