Browse Source

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

master
Daniel Berteaud 10 months ago
parent
commit
995a3921d9
1 changed files with 12 additions and 3 deletions
  1. +12
    -3
      zmbh/zmbh.pl

+ 12
- 3
zmbh/zmbh.pl View File

@@ -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