Laravel Backup

Automated database and file backups for Laravel apps, with cleanup and health monitoring

Tool
Composer
v10.3.1
6,018stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
80/100Excellent
Development Activity68
Maintenance72
Community80
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
79/100Good
Architecture82
Code Quality84
Innovation70
Learning Curve80

Laravel Backup by Spatie adds a set of Artisan commands that create a zip archive of your application’s files and a dump of your database, then ship it to one or more Flysystem-supported disks (S3, Dropbox, local disk, and others). Once installed, php artisan backup:run produces a backup on demand or on a schedule, while backup:clean prunes old backups according to configurable retention rules (keep all for N days, then daily, then weekly, then monthly).

Beyond the backup process itself, the package includes a monitoring layer: backup:monitor checks that recent, appropriately-sized backups exist on each configured destination and raises Laravel notifications (mail, Slack, or any Notification channel) when a backup is missing, stale, or unhealthy. It’s built on Spatie’s own db-dumper and temporary-directory libraries and is one of the most widely deployed Spatie Laravel packages.

What You Get

  • backup:run command that zips selected app files and dumps configured databases, then uploads to one or more disks
  • backup:clean command implementing tiered retention (keep-all, then daily, weekly, monthly, yearly) to bound storage growth
  • backup:monitor health checks that verify each destination has a recent, non-empty backup and can fail a scheduled job or CI step
  • Pluggable notification channels (Mail, Slack, and any Laravel Notification channel) for backup success/failure/health events
  • Support for multiple simultaneous backup destinations via Flysystem (S3, local disk, Dropbox, and others)
  • Encryption and password-protection options for the generated zip archive

Common Use Cases

  • Nightly scheduled backups of a Laravel app’s database and storage directory to S3, wired into Laravel’s task scheduler
  • Multi-destination redundancy — backing up simultaneously to local disk and an off-site S3 bucket
  • Automated cleanup that keeps daily backups for a week, weekly for a month, and monthly thereafter without manual pruning
  • Alerting the team via Slack when a scheduled backup fails to run or a destination’s backup goes stale
  • Pre-deployment or pre-migration safety snapshots triggered manually via artisan backup:run

Under The Hood

Architecture — The package is organized around discrete Tasks (backup creation, cleanup, monitoring) coordinated by Artisan Commands, with BackupDestination abstracting each configured storage disk and Notifications/Events/Listeners decoupling backup outcomes from how they’re reported; a Manifest (covered by ManifestTest) tracks which files were included in a given backup run. Tech Stack — Built on Laravel 12/13 (illuminate/* ^12.40|^13.0) and PHP 8.3+, delegating actual database dumping to Spatie’s own spatie/db-dumper, file storage abstraction to league/flysystem, and package bootstrapping to spatie/laravel-package-tools; it requires the zip PHP extension for archive creation. Code Quality — The tests/ directory includes dedicated suites for file-selection logic, dump-format handling, and manifest integrity (FileSelectionTest, FormatTest, ManifestTest, DbDumperFactoryTest), plus Larastan static analysis in CI; the codebase separates concerns cleanly across Commands/Tasks/Events rather than one monolithic backup class. API Design — Zero custom code is required for typical use — everything is configuration-driven through config/backup.php plus Laravel’s own scheduler ($schedule->command('backup:run')), making the barrier to a working nightly backup essentially one config file and one scheduled-command line.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search