gokulsingh / laravel-incremental-backup
Laravel package for full, incremental, and differential database backups with scheduling and cloud upload.
Requires
- php: >=8.0
- illuminate/support: ^10.0|^11.0
This package is auto-updated.
Last update: 2025-09-05 08:02:37 UTC
README
Full, Incremental & Differential Backups for Laravel — includes multi-database support, scheduling, cloud upload, and restore-from-cloud.
Installation
- Copy this package into your project's
vendor/
folder (e.g.vendor/gokulsingh/laravel-incremental-backup
) OR add it as a path repository in your main composer.json:
"repositories": [ { "type": "path", "url": "vendor/gokulsingh/laravel-incremental-backup" } ]
- Require it via composer:
composer require gokulsingh/laravel-incremental-backup:dev-main
- Publish config and run migrations:
php artisan vendor:publish --provider="Gokulsingh\\IncrementalBackup\\IncrementalBackupServiceProvider"
php artisan migrate
- Configure
.env
:
BACKUP_DISK=local BACKUP_PATH=backups BACKUP_CLOUD_ENABLED=true BACKUP_CLOUD_DISK=s3 BACKUP_CLOUD_PATH=cloud_backups # Optional: schedule defaults BACKUP_SCHEDULE_ENABLED=true BACKUP_SCHEDULE_FREQUENCY=daily BACKUP_SCHEDULE_TYPE=full BACKUP_SCHEDULE_CONNECTION=mysql BACKUP_SCHEDULE_DBNAME=null
Usage
Run a full backup
php artisan backup:run --type=full --connection=mysql
Run an incremental backup (mysql binlog required)
php artisan backup:run --type=incremental --connection=mysql
Run a differential backup (since last full)
php artisan backup:run --type=differential --connection=mysql
Override database name
php artisan backup:run --type=full --connection=mysql --dbname=customer_db
List backups
php artisan backup:list
Restore a backup by ID
php artisan backup:restore 1 --connection=mysql --dbname=customer_db
Notes & Requirements
-
MySQL binary logging must be enabled for incremental backups: Add to my.cnf:
[mysqld] server-id=1 log-bin=mysql-bin binlog_format=ROW
Restart MySQL after changes.
-
Differential backups in this MVP use
updated_at
filtering where possible. This is a heuristic; for robust differential backups consider triggers, change tables, or CDC. -
Cloud upload uses Laravel filesystem disks. Configure S3/Dropbox/etc in
config/filesystems.php
and setBACKUP_CLOUD_DISK
accordingly. -
The package uses system commands (
mysqldump
,mysql
,mysqlbinlog
,gzip
,gunzip
). Ensure they are available in PATH or override the commands inconfig/incremental-backup.php
.
Roadmap
- Improve binlog delta handling (store exact positions, incremental chains)
- Add optional encryption
- Add backup retention & cleanup
- Add UI dashboard & manual restore from UI
- Add notifications (Slack, email)
License
MIT