- How do I install and set up spatie/laravel-backup in a Laravel 12 project?
- Run `composer require spatie/laravel-backup`, then publish the config with `php artisan vendor:publish --tag=backup-config`. Edit `config/backup.php` to define your backup sources (files/databases) and destinations (e.g., S3, local disk). No additional setup is needed for basic usage.
- Can I back up to multiple storage destinations (e.g., S3 and local disk) simultaneously?
- Yes. Configure multiple disks in the `disks` array of your backup config. The package will create identical backups on all specified destinations. Example: `['s3', 'local']`.
- Does spatie/laravel-backup support incremental backups for large databases?
- No, it only creates full backups. However, you can exclude non-critical files or directories to reduce backup size. For true incremental backups, consider third-party tools like `mysqldump --single-transaction` or `pg_dump` with custom scripts.
- How do I schedule automated backups in Laravel?
- Add the backup command to your Laravel scheduler in `app/Console/Kernel.php` under `schedule()`. Example: `Schedule::command('backup:run')->dailyAt('2:00')`. Run `php artisan schedule:run` manually or use a cron job for production.
- What Laravel and PHP versions does spatie/laravel-backup support?
- The latest version supports Laravel 12+ and PHP 8.4+. Older versions (v3–v6) support Laravel 5.5–10.x and PHP 7.3–8.1. Check the [GitHub releases](https://github.com/spatie/laravel-backup/releases) for specific version compatibility.
- How do I encrypt backups before storing them on S3 or another filesystem?
- Enable encryption in your backup config by setting `'encryption' => true`. The package uses AES-256 encryption by default. For password management, store the encryption key in your `.env` file (e.g., `BACKUP_ENCRYPTION_KEY`).
- What happens if a backup fails? Can I get notifications?
- Yes. Configure notifications in `config/backup.php` under `notifications`. Supported channels include Slack, Email, and custom channels. Example: `['notifications' => ['notion', 'email']]`. The package will alert you if a backup fails or is corrupted.
- How do I clean up old backups automatically?
- Define retention rules in `config/backup.php` under `cleanup`. Example: `['cleanup' => ['retain_versions' => 7, 'prune' => true]]` retains the last 7 backups and deletes older ones. The cleanup runs automatically after each backup.
- Can I exclude specific files or directories from backups?
- Yes. Use the `exclude` option in your backup config. Example: `['exclude' => ['storage/logs', 'node_modules']]`. This skips specified directories during the backup process.
- Are there alternatives to spatie/laravel-backup for Laravel?
- Yes. Alternatives include `laravel-backup-manager` (for multi-disk backups), `spatie/laravel-db-dumper` (database-only backups), or custom scripts using `mysqldump`/`pg_dump` + `zip`. However, `spatie/laravel-backup` stands out for its seamless Laravel integration, monitoring, and multi-destination support.