Simple, zero-dependency database backups to S3 for Laravel applications
pgt/backup is a Laravel package for simple, zero-dependency database backups to s3 for laravel applications.
It currently has 1 GitHub stars and 114 downloads on Packagist (latest version v1.0.0).
Install it with composer require pgt/backup.
Discover more Laravel packages by pgt
or browse all Laravel packages to compare alternatives.
Last updated
A simple, zero-configuration Laravel package that backs up your database to S3 (or any Laravel filesystem disk) on a schedule.
storage/logs/pgt-backup.logmysqldump (MySQL) or pg_dump (PostgreSQL) installed on the servercomposer require pgt/backup
The service provider is auto-discovered. No manual registration needed.
Publish the config file:
php artisan vendor:publish --tag=pgt-backup-config
This creates config/pgt-backup.php. The defaults work out of the box if you have standard AWS_* environment variables set.
| Variable | Default | Description |
|---|---|---|
| BACKUP_DISK | s3 | Filesystem disk to upload to |
| BACKUP_PATH | pgt-backups | Directory path within the disk (root folder by default) |
| BACKUP_CONNECTION | (default DB connection) | Database connection to back up |
| BACKUP_REPLACE | false | Overwrite today's backup on re-run (date-only filename) |
| BACKUP_KEEP | (none) | Max number of backup files to retain |
| BACKUP_KEEP_FOR_DAYS | 30 | Delete backups older than this many days |
| BACKUP_CRON | 0 2 * * * | Cron schedule (default: 2am daily) |
| BACKUP_TIMEZONE | (app timezone) | Timezone for the schedule |
Both BACKUP_KEEP and BACKUP_KEEP_FOR_DAYS can be set simultaneously — a file is pruned if it violates either rule.
Add standard AWS credentials to your .env:
AWS_ACCESS_KEY_ID=your-key-id
AWS_SECRET_ACCESS_KEY=your-secret
AWS_DEFAULT_REGION=eu-west-2
AWS_BUCKET=your-bucket-name
Ensure your S3 bucket policy allows PutObject, GetObject, ListBucket, and DeleteObject for the credentials you provide.
Add Laravel's scheduler to your server cron (once — if not already done):
* * * * * cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1
The package registers its own schedule automatically. No changes to app/Console/Kernel.php are needed.
To disable the automatic schedule and run manually, set BACKUP_CRON= (empty) in your .env.
php artisan pgt:backup
Override the connection or disk at runtime:
php artisan pgt:backup --connection=mysql --disk=s3
Backups are stored as gzip-compressed SQL files. The filename format depends on the replace setting:
# replace = false (default) — one file per run, never overwritten
pgt-backups/2026-05-28_02-00-00_backup.sql.gz
# replace = true — one file per day, re-running the same day overwrites it
pgt-backups/2026-05-28_backup.sql.gz
Old backups are pruned automatically after each successful run based on your retention settings.
Each scheduled run appends output to:
storage/logs/pgt-backup.log
MIT — see LICENSE.