commit 7d3227423941965c79b9740d98177cf30a622914 Author: Thomas Date: Wed Apr 20 00:38:01 2022 +0200 initial commit diff --git a/.vmbackup.sh.swp b/.vmbackup.sh.swp new file mode 100644 index 0000000..e4a1bba Binary files /dev/null and b/.vmbackup.sh.swp differ diff --git a/vmbackup.sh b/vmbackup.sh new file mode 100755 index 0000000..edd2a37 --- /dev/null +++ b/vmbackup.sh @@ -0,0 +1,35 @@ +#! /bin/bash + +set -e +set -u + +outputdir=/mnt/backups/vms +if [ ! -d $outputdir ] ; then + echo outputdir not mounted + exit 41 +fi + +outputdir=${outputdir}/$(date -I) +mkdir -p ${outputdir} + +if [ $# -ne 1 ] ; then + echo "Usage: $O vm" + echo "Stop, backup and start given vm" + exit 42 +fi + +function checkRunning { + local machine=$1 + vboxmanage list runningvms | grep -q $machine + return $? +} + +machine=$1 +if ( checkRunning $machine ) ; then + echo vboxmanage controlvm $machine acpipowerbutton shutdown + sleep 60 + echo rsync -a /srv/VM/Win/roofline ${outputdir}/ + ret=$? + exit $ret +fi +exit 43