From: Bastian Dehn Date: Sun, 26 Nov 2017 10:16:50 +0000 (+0100) Subject: change: optimize VM backup reduce redundant code X-Git-Url: https://gitweb.hhaalo.de/?a=commitdiff_plain;h=fba7fb61e3a81c58a60db02a9241e79aced0934b;p=simple-backup.git change: optimize VM backup reduce redundant code --- diff --git a/backup b/backup index 50e0679..34262f0 100755 --- a/backup +++ b/backup @@ -58,6 +58,9 @@ printfStripLine() { ################################################################################ BackupVMDiscs() { + local readonly Disks=$(ssh $remoteLogin virsh domblklist $VM --details \ + | grep disk \ + | awk '{print $4}') local readonly logFile="$backRemotePCPath/backup-$(echo $Disk \ | sed 's/\//-/g').log" @@ -84,13 +87,8 @@ BackupOnlineVMs() { printfStripLine printf "Rechner %s; %s ist online\n" "$remoterechner" "$VM" printf "Fahre %s herunter\n\n" "$VM" - ssh $remoteLogin virsh shutdown $VM | WaitVMShutdown - Disks=$(ssh $remoteLogin virsh domblklist $VM --details \ - | grep disk \ - | awk '{print $4}') BackupVMDiscs - printf "\nFahre %s hoch\n" "$VM" ssh $remoteLogin virsh start $VM printfStripLine @@ -105,10 +103,6 @@ BackupOfflineVMs() { for VM in $offlineVM; do printfStripLine printf "Rechner %s; %s ist offline\n\n" "$remoterechner" "$VM" - - Disks=$(ssh $remoteLogin virsh domblklist $VM --details \ - | grep disk \ - | awk '{print $4}') BackupVMDiscs printfStripLine done