Created
August 23, 2017 22:18
-
-
Save mkouhei/19ee7e4a3db6838c2db159de619f4ea4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh -e | |
vmname=$1 | |
VBoxManage showvminfo $vmname | grep State: | grep -q 'powered off' || ( echo "VM: $vmname is not powered off." ; exit 1 ) | |
VBoxManage snapshot $vmname take $(date +%Y%m%d-%H%M) | |
if [ $(VBoxManage snapshot $vmname list | wc -l) -lt 4 ]; then | |
exit 0 | |
fi | |
VBoxManage snapshot $vmname delete $(VBoxManage snapshot $vmname list | head -1 | awk '{print $2}') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment