stefanzweifel / laravel-backup-restore

A package to restore database backups made with spatie/laravel-backup.
https://stefanzweifel.dev/posts/2023/06/15/introducing-laravel-backup-restore
MIT License
165 stars 15 forks source link

Add Health Checks #11

Closed stefanzweifel closed 1 year ago

stefanzweifel commented 1 year ago

This PR adds a new feature to the package: health checks.

The backup:restore command already fails, if the backup couldn't be downloaded, extracted or imported. But what if the import process succeeds but the database is in a non-nominal state?

With health checks, we can ensure that the database contains the tables or data, to confirm that the restore process was truly successful. The package ships with a DatabaseHasTables-check to ensure the database contains at least one databae table. This check is the simplest form of a health check and doesn't make any assumptions how an app of the package consumer works.

Consumers are encouraged to write their own health checks for their applications. For example, one could write a check that ensures, that the database contains data from yesterday; assuming one creates daily backups and runs the restore command on a daily basis. (eg. through Laravel's schedule feature or GitHub Actions).

TODOs


This feature has been heavily inspired by Spatie's laravel-health package.