protected function backupDestinationProperties() : Collection
 {
     $backupDestination = $this->backupDestination();
     if (!$backupDestination) {
         return collect();
     }
     $newestBackup = $backupDestination->newestBackup();
     $oldestBackup = $backupDestination->oldestBackup();
     return collect(['Application name' => $this->applicationName(), 'Disk' => $backupDestination->diskName(), 'Newest backup size' => $newestBackup ? Format::humanReadableSize($newestBackup->size()) : 'No backups were made yet', 'Amount of backups' => strval($backupDestination->backups()->count()), 'Total storage used' => Format::humanReadableSize($backupDestination->backups()->size()), 'Newest backup date' => $newestBackup ? $newestBackup->date()->format('Y/m/d H:i:s') : 'No backups were made yet', 'Oldest backup date' => $oldestBackup ? $oldestBackup->date()->format('Y/m/d H:i:s') : 'No backups were made yet'])->filter();
 }
Example #2
0
 public function convertToRow(BackupDestinationStatus $backupDestinationStatus) : array
 {
     $row = [$backupDestinationStatus->backupName(), $backupDestinationStatus->diskName(), Format::emoji($backupDestinationStatus->isReachable()), Format::emoji($backupDestinationStatus->isHealthy()), 'amount' => $backupDestinationStatus->amountOfBackups(), 'newest' => $backupDestinationStatus->dateOfNewestBackup() ? Format::ageInDays($backupDestinationStatus->dateOfNewestBackup()) : 'No backups present', 'usedStorage' => $backupDestinationStatus->humanReadableUsedStorage()];
     if (!$backupDestinationStatus->isReachable()) {
         foreach (['amount', 'newest', 'usedStorage'] as $propertyName) {
             $row[$propertyName] = '/';
         }
     }
     $row = $this->applyStylingToRow($row, $backupDestinationStatus);
     return $row;
 }
Example #3
0
 public function run()
 {
     $this->backupDestinations->each(function (BackupDestination $backupDestination) {
         try {
             if (!$backupDestination->isReachable()) {
                 throw new Exception("Could not connect to disk {$backupDestination->diskName()} because: {$backupDestination->connectionError()}");
             }
             consoleOutput()->info("Cleaning backups of {$backupDestination->backupName()} on disk {$backupDestination->diskName()}...");
             $this->strategy->deleteOldBackups($backupDestination->backups());
             event(new CleanupWasSuccessful($backupDestination));
             $usedStorage = Format::humanReadableSize($backupDestination->usedStorage());
             consoleOutput()->info("Used storage after cleanup: {$usedStorage}.");
         } catch (Exception $exception) {
             consoleOutput()->error("Cleanup failed because: {$exception->getMessage()}.");
             event(new CleanupHasFailed($exception));
         }
     });
 }
Example #4
0
 public function humanReadableSize() : string
 {
     return Format::humanReadableSize($this->size());
 }
 public function humanReadableUsedStorage() : string
 {
     return Format::humanReadableSize($this->usedStorage());
 }