When failing to create a snapshot, restart stopped services before dying

master
Daniel Berteaud 5 years ago
parent 2592b82c31
commit 995a3921d9
  1. 15
      zmbh/zmbh.pl

@ -59,6 +59,9 @@ if ( $can_snapshot ) {
}
if ( $opt->{pre} ) {
my $failure = 0;
if ($opt->{shutdown} =~ m/^no(ne)?/){
log_info("Not shutting down any service");
} elsif ($opt->{shutdown} eq 'ldap' and -e '/opt/zimbra/bin/ldap'){
@ -91,11 +94,13 @@ if ( $opt->{pre} ) {
# Take the snapshot
if ( system( "lvcreate $snap_args $dev") != 0 ) {
die "Failed to create snapshot\n";
log_info("Failed to create snapshot");
# Record the failure but don't die now, we need to restart services
$failure = 1;
} else {
log_info("snapshot created as $dev" . '_bkp');
}
log_info("snapshot created as $dev" . '_bkp');
# Restart Zimbra now to minimize down time
if ($opt->{shutdown} =~ m/^no(ne)?/){
log_info("No service were shutted down");
@ -124,6 +129,10 @@ if ( $opt->{pre} ) {
system('systemctl start zimbra');
}
if ($failure){
die "Stoping backup process now, as snapshot failed\n";
}
# Now mount the snapshot RO
my $mount_args = "-o ro -t $fs";
if ( $fs eq 'xfs' ) {

Loading…
Cancel
Save