initial commit
This commit is contained in:
BIN
.vmbackup.sh.swp
Normal file
BIN
.vmbackup.sh.swp
Normal file
Binary file not shown.
35
vmbackup.sh
Executable file
35
vmbackup.sh
Executable file
@@ -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
|
||||
Reference in New Issue
Block a user