Download the PHP package hassan-shahriar-1/laravel-google-drive-backup without Composer
On this page you can find all versions of the php package hassan-shahriar-1/laravel-google-drive-backup. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download hassan-shahriar-1/laravel-google-drive-backup
More information about hassan-shahriar-1/laravel-google-drive-backup
Files in hassan-shahriar-1/laravel-google-drive-backup
Package laravel-google-drive-backup
Short Description Policy-based Laravel backup management with Google Drive as a backup destination.
License MIT
Homepage https://github.com/Hassan-Shahriar-1/laravel-google-drive-backup
Informations about the package laravel-google-drive-backup
Laravel Google Drive Backup
Policy-based Laravel backup management with Google Drive as a backup destination.
This package provides a focused integration layer that connects Laravel applications to Google Drive for automated backups with configurable multi-tier retention (daily / weekly / monthly), post-upload integrity verification, and a full suite of Artisan commands — all without replacing your existing backup engine.
Features
- ✅ Google OAuth 2.0 authentication with refresh token support
- ✅ Interactive CLI command (
backup:google-drive:refresh-token) to generate OAuth refresh tokens - ✅ Chunked, streaming upload for large backup archives (no memory exhaustion)
- ✅ Paginated backup listing from Google Drive
- ✅ Multi-tier retention policy (daily, weekly, monthly) with overlap protection
- ✅ Post-upload verification (
metadata,checksum, orfull-downloadmodes) - ✅ Deterministic filename generation with UTC timestamps
- ✅ Automatic temp-file cleanup with
try/finallysafety - ✅ Laravel events for every lifecycle stage
- ✅ Full Artisan CLI suite
- ✅ 90%+ test coverage with PHPUnit 11 + Orchestra Testbench 10
- ✅ Credential sanitization — secrets are never written to logs or exceptions
Requirements
| Package | Version |
|---|---|
| PHP | ^8.3 | ^8.4 | ^8.5 |
| Laravel | >= 10.0 (supports 10.x, 11.x, 12.x, 13.x+) |
Installation
Publish the configuration file:
Google Drive Setup
See docs/google-drive-setup.md for step-by-step instructions on creating a Google Cloud project, enabling the Drive API, and obtaining an OAuth 2.0 refresh token.
Configuration
Add these variables to your .env:
Full configuration reference: docs/configuration.md
Quick Start
Test your connection:
Run your first backup:
List backups on Google Drive:
Database Backups & Supported Drivers
The package natively dumps and restores all major database drivers used in Laravel:
| Driver | Engine | Tool Used |
|---|---|---|
mysql |
MySQL | mysqldump |
mariadb |
MariaDB | mysqldump |
pgsql |
PostgreSQL | pg_dump |
sqlite |
SQLite | sqlite3 (or raw file copy) |
sqlsrv |
SQL Server / Azure SQL | sqlcmd |
Database Backup Examples
Database Restore
Subfolder Organization (Folder Separation)
By default, backups are uploaded directly into the root folder specified in your .env (GOOGLE_DRIVE_BACKUP_FOLDER_ID or GOOGLE_DRIVE_BACKUP_FOLDER_NAME).
If you want to separate backups into subfolders (e.g. database/, others/):
1. Specify a Subfolder in the Command
2. Auto-organize by Backup Type (--by-type)
3. Listing Backups (Root and Subfolders)
Backing Up Specific Folders or Files (--path)
By default, --files archives your entire application (excluding vendor, node_modules, .git, etc.).
If you only need to back up specific folders (such as uploaded images, documents, or media), use the --path option:
Note: If
--pathis passed, the backup type automatically defaults tofileswithout needing to pass--filesexplicitly.
Artisan Commands
| Command | Description |
|---|---|
backup:google-drive:refresh-token |
Interactively generate OAuth refresh token & save to .env |
backup:google-drive |
Create and upload a backup |
backup:google-drive:test |
Test credentials and folder access |
backup:google-drive:list |
List remote backups across root & subfolders (or filter with --subfolder=) |
backup:google-drive:clean |
Apply retention policy and delete expired backups |
backup:google-drive:verify |
Verify remote backup integrity |
backup:google-drive:download {id} {destination} |
Download a backup locally |
backup:google-drive:restore-db {id} |
Download a backup and restore the database (alias: restore) |
Use --dry-run with backup:google-drive:clean to preview what would be deleted without making changes.
Scheduling
Add to your routes/console.php (Laravel 11, 12, 13+):
Retention Policy
The retention engine works automatically like Spatie's cleanup strategy — you do not pass dates or intervals on the command line. It reads timestamps on Google Drive and groups backups by type (database vs files) so frequent database backups never delete file backups.
A backup that qualifies for multiple retention tiers (e.g. both daily and weekly) is never deleted until it expires from all applicable tiers.
Events
Listen to backup lifecycle events in your application:
Available events: BackupStarted, BackupCreated, BackupUploaded, BackupVerified, BackupFailed, BackupDeleted, CleanupCompleted.
Testing
Security
- OAuth tokens are never written to logs or stack traces.
- Temporary backup files are always deleted after use.
- Filenames are sanitized against path-traversal attacks.
- See SECURITY.md for the vulnerability reporting policy.
Documentation
| Topic | Link |
|---|---|
| Installation | docs/installation.md |
| Google Drive Setup | docs/google-drive-setup.md |
| Configuration | docs/configuration.md |
| Retention Policy | docs/retention.md |
| Commands | docs/commands.md |
| Scheduling | docs/scheduling.md |
| Restoration | docs/restoration.md |
| Security | docs/security.md |
| Troubleshooting | docs/troubleshooting.md |
Compatibility
| Package | Laravel | PHP |
|---|---|---|
| 2.x | 10.x / 11.x / 12.x / 13.x+ | 8.3+ |
License
MIT © Hassan Shahriar — see LICENSE.
All versions of laravel-google-drive-backup with dependencies
google/apiclient Version ^2.15
illuminate/console Version >=10.0
illuminate/filesystem Version >=10.0
illuminate/support Version >=10.0