From 5178dfd6e83449a4558924fbc358e28085152c66 Mon Sep 17 00:00:00 2001 From: cig Date: Fri, 16 Sep 2022 08:06:47 +0200 Subject: [PATCH] reorganize script's functions --- vmbackup.sh | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/vmbackup.sh b/vmbackup.sh index b0f31f8..cf91195 100755 --- a/vmbackup.sh +++ b/vmbackup.sh @@ -2,6 +2,7 @@ set -e set -u +set -o pipefail statusfile=/var/run/zabbix/vmbackup.status basedir=/mnt/backups/vms @@ -17,6 +18,17 @@ _mail () { echo "$@" | mail -s "$(hostname -f) : vm backup error" root } +function checkRunning { + local machine=$1 + $vbm list runningvms | grep -q $machine + return $? +} + +function _shutdown_vm { + net rpc shutdown -I 192.168.69.250 -U tom%123Soleil2022! + sleep 30 +} + mount /mnt/backups &> /dev/null || _exit "mount failed" 2 if [ ! -d $basedir ] ; then @@ -32,17 +44,6 @@ if [ $# -ne 1 ] ; then _exit "Usage" 42 fi -function checkRunning { - local machine=$1 - $vbm list runningvms | grep -q $machine - return $? -} - -function _shutdown_vm { - net rpc shutdown -I 192.168.69.250 -U tom%123Soleil2022! - sleep 30 -} - machine=$1 if ( checkRunning $machine ) ; then mkdir -p ${outputdir}