From fba7fb61e3a81c58a60db02a9241e79aced0934b Mon Sep 17 00:00:00 2001 From: Bastian Dehn Date: Sun, 26 Nov 2017 11:16:50 +0100 Subject: [PATCH] change: optimize VM backup reduce redundant code --- backup | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) 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 -- 2.39.5