Gracefully handle LVM snapshot error with file based disk: just like with block, warn and disable the live backup, but do not fail

tags/virt-backup-0.2.12-1
Daniel Berteaud 11 years ago
parent 4de1d2c82b
commit 3135bff066
  1. 14
      virt-backup

@ -358,6 +358,7 @@ sub prepare_backup{
my $mp = $lvm; my $mp = $lvm;
$mp =~ s!/!_!g; $mp =~ s!/!_!g;
$mp = "$backupdir.mount/$mp"; $mp = "$backupdir.mount/$mp";
my $file = $source;
# Try to snapshot this device # Try to snapshot this device
if ( $opts{snapshot} ){ if ( $opts{snapshot} ){
# Maybe the LVM is already snapshoted and mounted for a previous disk ? # Maybe the LVM is already snapshoted and mounted for a previous disk ?
@ -370,7 +371,11 @@ sub prepare_backup{
} }
# Force the cache to be flushed before taking the snapshot # Force the cache to be flushed before taking the snapshot
die "Couldn't call sync before taking the snapshot: $!\n" unless (system ("/bin/sync") == 0); die "Couldn't call sync before taking the snapshot: $!\n" unless (system ("/bin/sync") == 0);
if (!$is_mounted && create_snapshot($lvm,$time)){ if ($is_mounted){
print "A snapshot of $lvm is already mounted on $backupdir.mount/$mp\n\n" if ($opts{debug});
$file =~ s|$mount|$mp|;
}
elsif (create_snapshot($lvm,$time)){
print "$lvm seems to be a valid logical volume (LVM), a snapshot has been taken as " . print "$lvm seems to be a valid logical volume (LVM), a snapshot has been taken as " .
$lvm . $time ."\n" if ($opts{debug}); $lvm . $time ."\n" if ($opts{debug});
my $snap = $lvm.$time; my $snap = $lvm.$time;
@ -387,9 +392,12 @@ sub prepare_backup{
open MOUNT, ">$backupdir.meta/mount"; open MOUNT, ">$backupdir.meta/mount";
print MOUNT $lvm; print MOUNT $lvm;
close MOUNT; close MOUNT;
$file =~ s|$mount|$mp|;
}
else {
print "An error occured while snapshoting $lvm, live backup will be disabled\n" if ($opts{debug});
$opts{livebackup} = 0;
} }
my $file = $source;
$file =~ s|$mount|$mp|;
push (@disks, {source => $file, target => $target, type => 'file'}); push (@disks, {source => $file, target => $target, type => 'file'});
} }
else { else {

Loading…
Cancel
Save