Remember when backing up your Laravel app meant just dumping files to a local folder? Those days are over.
Laravel Backup v2.0 now supports multi-destination backups to Google Drive and S3-compatible storage (AWS, Backblaze B2, MinIO, DigitalOcean Spaces) - all simultaneously.
The Upgrade Story
v1.0: "Backup to local storage"
v2.0: "Backup everywhere at once"
Let's Set This Up
Step 1: Install
composer require avcodewizard/laravel-backup
composer require google/apiclient # For Google Drive
composer require aws/aws-sdk-php # For S3
Config auto-publishes. No vendor:publish needed. ✨
Step 2: Google Drive (OAuth 2.0)
The cool part: The auth command accepts your full redirect URL OR just the code.
php artisan backup:google-auth
Visit this URL: https://accounts.google.com/o/oauth2/...
Paste the full URL or authorization code:
> http://localhost/?code=4/0AeoWuM8YPEQ33BC09c...
=== SUCCESS ===
GOOGLE_DRIVE_REFRESH_TOKEN=1//0g4fGXguTx9gVCgYIARA...
Copy that refresh token to your .env and you're set for life (well, until you revoke it).
Step 3: S3 / Backblaze B2
Backblaze B2 is S3-compatible and offers 10GB free. Perfect for testing.
AWS_ACCESS_KEY_ID=your-b2-key-id
AWS_SECRET_ACCESS_KEY=your-b2-secret
AWS_DEFAULT_REGION=us-east-005
AWS_BUCKET=laravel-backups
AWS_ENDPOINT=https://s3.us-east-005.backblazeb2.com
Step 4: Configure
// config/laravelBackup.php
'destinations' => [
'local' => [
'enabled' => true,
'path' => storage_path('backups'),
],
's3' => [
'enabled' => true,
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION'),
'bucket' => env('AWS_BUCKET'),
'endpoint' => env('AWS_ENDPOINT'),
'path' => 'backups',
],
'google_drive' => [
'enabled' => true,
'client_id' => env('GOOGLE_DRIVE_CLIENT_ID'),
'client_secret' => env('GOOGLE_DRIVE_CLIENT_SECRET'),
'refresh_token' => env('GOOGLE_DRIVE_REFRESH_TOKEN'),
'folder_id' => env('GOOGLE_DRIVE_FOLDER_ID'),
'path' => 'backups',
],
],
'keep_days' => 7,
'cleanup_scope' => 'all', // or 'local'
Step 5: Run It
php artisan backup:run
Watch the magic happen:
Creating database backup...
Uploading to local... ✅
Uploading to s3... ✅
Uploading to google_drive... ✅
Cleaning up old backups...
Backup completed successfully!
Step 6: Automate It
Add to routes/console.php (Laravel 11+):
use Illuminate\Support\Facades\Schedule;
Schedule::call(function () {
Artisan::call('backup:run');
})->name('backup:run')->withoutOverlapping()->daily();
Or for older Laravel (app/Console/Kernel.php):
$schedule->command('backup:run')->daily();
The Web UI
Navigate to /laravel-backup and see all your backups across destinations:
- Database backups
- Storage backups
- File sizes
- Storage locations
- One-click downloads
- Delete across all destinations
Why This Approach?
Official SDKs > Flysystem adapters
- Clear error messages (no "disk not found" mysteries)
- Full API support (shared drives, custom endpoints, etc.)
- OAuth 2.0 flow for Google (industry standard)
- Better debugging
Quick Tips
- Test user for Google: If you see "Access blocked", add your email as a test user in Google Cloud Console
- Backblaze free tier: 10GB free, perfect for side projects
-
cleanup_scope: Set to
'local'if you want cloud backups kept forever
Try It Out
composer require avcodewizard/laravel-backup
GitHub: avcodewizard/laravel-backup
What backup strategy do you use? Single destination or multi-cloud? Drop a comment! 👇
Top comments (0)