webteractive / filament-google-drive-backup-manager
A Filament plugin for managing Google Drive backups in Laravel
Package info
github.com/webteractive/filament-google-drive-backup-manager
pkg:composer/webteractive/filament-google-drive-backup-manager
Requires
- php: ^8.4
- calebporzio/sushi: ^2.5
- filament/filament: ^4.0||^5.0
- illuminate/contracts: ^11.0||^12.0
- laravel/socialite: ^5.26
- masbug/flysystem-google-drive-ext: ^2.3
- spatie/laravel-backup: ^9.0||^10.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- larastan/larastan: ^3.0
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.8
- orchestra/testbench: ^10.0.0||^9.0.0
- pestphp/pest: ^4.0
- pestphp/pest-plugin-arch: ^4.0
- pestphp/pest-plugin-laravel: ^4.0
- phpstan/extension-installer: ^1.4
- phpstan/phpstan-deprecation-rules: ^2.0
- phpstan/phpstan-phpunit: ^2.0
- spatie/laravel-ray: ^1.35
README
A Filament plugin for managing Spatie Laravel Backup files stored on Google Drive. View, download, delete, and trigger backups directly from your Filament admin panel.
Requirements
- PHP 8.4+
- Laravel 11+
- Filament 4.0+
- Spatie Laravel Backup 9.0+
Installation
composer require webteractive/filament-google-drive-backup-manager
Publish the config file:
php artisan vendor:publish --tag="google-drive-backup-manager-config"
Google Drive Setup
Add your Google OAuth credentials to the published config file (config/google-drive-backup-manager.php):
'google' => [ 'client_id' => env('GOOGLE_DRIVE_CLIENT_ID'), 'client_secret' => env('GOOGLE_DRIVE_CLIENT_SECRET'), 'redirect' => env('GOOGLE_DRIVE_REDIRECT_URI'), ],
Then add a google disk to your config/filesystems.php:
'disks' => [ 'google' => [ 'driver' => 'google', 'folder' => env('GOOGLE_DRIVE_FOLDER', '/'), ], ],
Add the corresponding values to your .env file:
GOOGLE_DRIVE_CLIENT_ID=your-client-id GOOGLE_DRIVE_CLIENT_SECRET=your-client-secret GOOGLE_DRIVE_REDIRECT_URI=https://yourapp.com/google-drive-backup-manager-oauth/callback GOOGLE_DRIVE_FOLDER=/
The refresh token is automatically resolved from the user who connected their Google account via the admin panel. No manual token configuration needed.
Filament Panel Registration
Register the plugin in your Filament panel provider:
use Webteractive\GoogleDriveBackupManager\GoogleDriveBackupManagerPlugin; public function panel(Panel $panel): Panel { return $panel // ... ->plugins([ GoogleDriveBackupManagerPlugin::make(), ]); }
Authorization
Access to the backup manager is controlled by a Laravel Gate. By default, the gate name is viewBackups. Define it in your AppServiceProvider:
use Illuminate\Support\Facades\Gate; Gate::define('viewBackups', function ($user) { return $user->is_admin; });
You can change the gate name in the config:
'gate' => 'yourCustomGate',
Configuration
All settings are in config/google-drive-backup-manager.php:
return [ // Storage disk name (must match a disk in config/filesystems.php) 'disk' => 'google', // Laravel Gate for authorization 'gate' => 'viewBackups', // Filament sidebar navigation group 'navigation_group' => 'System', // Sidebar sort order 'navigation_sort' => 5, // Named route for downloading backups 'download_route' => 'backup.download', // Column on users table for storing Google OAuth tokens 'google_token_column' => 'google_backup', // Queue name for backup jobs (null = default queue) 'queue' => null, // Google OAuth credentials (kept within this package's config) 'google' => [ 'client_id' => env('GOOGLE_DRIVE_CLIENT_ID'), 'client_secret' => env('GOOGLE_DRIVE_CLIENT_SECRET'), 'redirect' => env('GOOGLE_DRIVE_REDIRECT_URI'), ], // Route middleware 'middleware' => ['web', 'auth'], // Base path for OAuth routes 'oauth_base_path' => 'google-drive-backup-manager-oauth', ];
Scheduling Backups
This plugin provides an on-demand UI for triggering backups, but does not schedule them automatically. To run backups on a schedule, add the Spatie backup commands to your application's routes/console.php:
use Illuminate\Support\Facades\Schedule; Schedule::command('backup:run')->daily()->at('02:00'); Schedule::command('backup:clean')->daily()->at('03:00');
Refer to the Spatie Laravel Backup docs for scheduling options, notification setup, cleanup strategies, and other configuration.
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.