Skip to main content

Included Artisan Commands

The package includes two robust commands for managing database backups directly from the CLI.

easy-backups:db:create

Creates a new atomic database backup.

php artisan easy-backups:db:create {--of-database=} {--to-disk=} {--compress} {--password=} {--name=} {--max-remote-backups=} {--max-remote-days=} {--local}

Options

OptionDescriptionDefault Behavior
--of-databaseThe database connection name to back up.Defaults to your application's default connection.
--to-diskThe filesystem disk to store the backup on.Defaults to backup (or configured remote disk).
--compressForce compression into a .zip or .tar.gz archive.If omitted, behavior depends on config.
--passwordEncrypt the backup with this password. Implies compression.No encryption.
--nameA custom suffix for the filename.
--max-remote-backupsNumber of backups to keep on the remote disk.No cleanup is performed.
--max-remote-daysDelete backups older than N days on remote.No cleanup is performed.
--localStore the backup only on the local disk.Uploads to remote disk.

Usage Examples

Standard backup to Remote Storage (Default):

php artisan easy-backups:db:create --compress

Local-only snapshot with a name:

php artisan easy-backups:db:create --local --name="pre-migration"

Backup with retention policy (keep last 10):

php artisan easy-backups:db:create --max-remote-backups=10

Backup with age-based retention (keep 30 days):

php artisan easy-backups:db:create --max-remote-days=30

easy-backups:db:restore

Restores a database from a backup. Runs in interactive mode by default.

php artisan easy-backups:db:restore {--latest} {--from-disk=} {--to-database=} {--source-env=} {--password=} {--local}

Options

OptionDescriptionDefault Behavior
--from-diskThe filesystem disk where the backup is stored.Defaults to backup.
--to-databaseThe target database connection to overwrite.Defaults to default connection.
--source-envThe environment to pull backups from (e.g., production).Defaults to current environment.
--latestRestore the latest backup immediately without prompting.Runs interactive selection.
--passwordPassword for encrypted backups.
--localForce using the local disk as source.Uses remote disk.

Usage Examples

Interactive restore:

php artisan easy-backups:db:restore

Restore latest backup (Automated):

php artisan easy-backups:db:restore --latest

Restore a backup from the staging environment:

php artisan easy-backups:db:restore --source-env=staging

Restore from local storage:

php artisan easy-backups:db:restore --local