Laravel Backup
Automated database and file backups for Laravel apps, with cleanup and health monitoring
Repository Health
Technical Analysis
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:runcommand that zips selected app files and dumps configured databases, then uploads to one or more disksbackup:cleancommand implementing tiered retention (keep-all, then daily, weekly, monthly, yearly) to bound storage growthbackup:monitorhealth 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.
Used by 3 apps in this directory
Crater
Invoicing Finance
Open source invoicing and billing platform for freelancers and small businesses — create estimates, track expenses, accept Stripe payments, and run recurring invoices from your own server.
LinkStack
Marketing
Self-hosted, privacy-focused Linktree alternative with themes, analytics, and a drag-and-drop admin panel.
Pixelfed
Social Media
A decentralized, self-hosted photo sharing platform built on ActivityPub for the open Fediverse.