Skip to content

Commit

Permalink
Check if backup destination is reachable before trying to copy backup (
Browse files Browse the repository at this point in the history
…#1469)

* add check if backup destination is reachable before trying to copy zip file

* throw exception in catch statement to avoid wrong global status with 0 when an error occurred
  • Loading branch information
smknstd authored Feb 13, 2022
1 parent 96609e2 commit f231017
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Tasks/Backup/BackupJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,10 @@ protected function copyToBackupDestinations(string $path): void
$this->backupDestinations
->each(function (BackupDestination $backupDestination) use ($path) {
try {
if (! $backupDestination->isReachable()) {
throw new Exception("Could not connect to disk {$backupDestination->diskName()} because: {$backupDestination->connectionError()}");
}

consoleOutput()->info("Copying zip to disk named {$backupDestination->diskName()}...");

$backupDestination->write($path);
Expand All @@ -294,6 +298,8 @@ protected function copyToBackupDestinations(string $path): void
consoleOutput()->error("Copying zip failed because: {$exception->getMessage()}.");

$this->sendNotification(new BackupHasFailed($exception, $backupDestination ?? null));

throw $exception;
}
});
}
Expand Down

0 comments on commit f231017

Please sign in to comment.