The Laravel Backup Restore is a bundle to revive database backups made with Spatie’s laravel-backup bundle:
Including the ending touches on laravel-backup-restore.
At present writing a weblog submit explaining the whole lot.
v1 must be tagged by mid June.https://t.co/uRubDv4CDw— Stefan Zweifel (@_stefanzweifel) Might 31, 2023
This bundle gives an Artisan command to revive a backup in addition to some customizable well being checks and backup integrity checks. This is an instance of the artisan command from the challenge’s README:
php artisan backup:restore
--disk=s3
--backup=newest
--connection=mysql
--password=my-secret-password
--reset
After the backup is restored, this bundle will run some well being checks to verify the backup was restored efficiently. It checks for issues like ensuring the database has tables. You may add your personal customized checks as effectively that you could configure to run after a backup:restore:
namespace AppHealthChecks;
use WnxLaravelBackupRestorePendingRestore;
use WnxLaravelBackupRestoreHealthChecksHealthCheck;
class MyCustomHealthCheck extends HealthCheck
{
public operate run(PendingRestore $pendingRestore): Consequence
{
$end result = Consequence::make($this);
// We assume that your app generates gross sales day-after-day.
// This test ensures that the database accommodates gross sales from yesterday.
$newSales = AppModelsSale::question()
->whereBetween('created_at', [
now()->subDay()->startOfDay(),
now()->subDay()->endOfDay()
])
->exists();
// If no gross sales had been created yesterday, we take into account the restore as failed.
if ($newSales === false) {
return $end result->failed('Database accommodates no gross sales from yesterday.');
}
return $end result->okay();
}
}
Be sure you take a look at the bundle’s readme for an instance of a GitHub motion you should use to validate your backup integrity incrementally.
You may study extra about this bundle, get full set up directions, and look at the supply code on GitHub.