When failing to create a snapshot, restart stopped services before dying
This commit is contained in:
parent
2592b82c31
commit
995a3921d9
15
zmbh/zmbh.pl
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…
Reference in New Issue