How to get the backup list programatically? #1443
-
I can see the list of backups using |
Beta Was this translation helpful? Give feedback.
Answered by
freekmurze
Dec 15, 2021
Replies: 2 comments 1 reply
-
Take a look at the code of that command. Should be fairly straightforward to understand what is going on. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
freekmurze
-
In case anyone else wants to do this, here's how I extracted this info into a simple array structure: public function getBackupInfo()
{
$statuses = BackupDestinationStatusFactory::createForMonitorConfig(config('backup.monitor_backups'));
$info = [];
foreach ($statuses as $status) {
$destination = $status->backupDestination();
$backups = $destination->backups();
$destInfo = [
'name' => $destination->backupName(),
'disk' => $destination->diskName(),
'storageType' => $destination->filesystemType(),
'reachable' => $destination->isReachable(),
'healthy' => $status->isHealthy(),
'count' => $backups->count(),
'storageSpace' => $destination->usedStorage(),
'backups' => [],
];
foreach ($backups as $backup) {
$destInfo['backups'][] = [
'path' => $backup->path(),
'date' => $backup->date(),
'size' => $backup->sizeInBytes(),
];
}
$info[] = $destInfo;
}
return $info;
} |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Take a look at the code of that command. Should be fairly straightforward to understand what is going on.