From 3a5ebf960e8cc4e4d4fc60c3f217da766f57ad12 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Fri, 2 May 2014 10:10:24 +0200 Subject: [PATCH] Fix create_snapshot if snapshoting failed even without a lock --- virt-backup | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/virt-backup b/virt-backup index 1e0ed98..cf7feb5 100644 --- a/virt-backup +++ b/virt-backup @@ -785,13 +785,13 @@ sub create_snapshot{ print "Running: $cmd" if $opts{debug}; if (-e "$lock" . '.lock'){ print "Volume $blk is locked...\n" if $opts{debug}; - sleep(1); } else{ open ( LOCK, ">$lock" ); print LOCK ""; close LOCK; if ( system("$cmd") == 0 ) { + print "Snapshot taken\n" if $opts{debug}; $ret = 1; open SNAPLIST, ">>$backupdir.meta/snapshots" or die "Error, couldn't open snapshot list file\n"; print SNAPLIST $blk.$suffix ."\n"; @@ -799,7 +799,11 @@ sub create_snapshot{ # break the loop now $cnt = 10; } + else{ + print "An error occured, couldn't create the snapshot" if $opts{debug}; + } } + sleep(1); } # In any case, failed or not, remove our lock unlink $lock if (-e $lock);