public static humanReadableSize ( integer $sizeInBytes ) : string | ||
$sizeInBytes | integer | |
return | string |
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(); }
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)); } }); }
public function humanReadableSize() : string { return Format::humanReadableSize($this->size()); }
public function humanReadableUsedStorage() : string { return Format::humanReadableSize($this->usedStorage()); }