Skip to main content

Included Artisan Commands

The package includes a set of basic quickstart Artisan commands.

aaix:backup:db:create

Creates a simple database backup. This command is intended for manual triggers or as a basic template for creating your own, more advanced backup commands.

php artisan aaix:backup:db:create {--of-database=} {--to-disk=} {--compress} {--password=}

Options

OptionDescriptionDefault Behavior
--of-databaseThe database connection name to back up.Defaults to your application's default database connection.
--to-diskThe filesystem disk to store the backup on.Defaults to 'local'.
--compressA flag to compress the final backup into a .zip archive.If omitted, an uncompressed .sql file is stored.
--passwordThe password to encrypt the backup archive. Using this option implicitly enables compression.The backup is not encrypted.

Usage Examples

Create a simple backup of the default database:

# Creates an uncompressed backup of the default DB on the 'local' disk
php artisan aaix:backup:db:create

Create a compressed backup of a specific database on S3:

# Creates a compressed backup of the 'pgsql' database on the 's3' disk
php artisan aaix:backup:db:create --of-database=pgsql --to-disk=s3 --compress

Create an encrypted backup of the default database:

# Creates a compressed, encrypted backup on the 'local' disk
php artisan aaix:backup:db:create --password="your-secret-password"

aaix:backup:db:restore

Restores a database from a backup. This command is a powerful tool for development and can be run in two modes:

  1. Interactive Mode (Default): If run without the --latest flag, it will present an interactive prompt allowing you to select a backup from a list of the 30 most recent files on the specified disk.
  2. Automated Mode: When the --latest flag is used, it will automatically find and restore the most recent backup, which is ideal for scripting.
php artisan aaix:backup:db:restore {--latest} {--from-disk=} {--to-database=} {--password=}

Options

OptionDescriptionDefault Behavior
--from-diskThe filesystem disk where the backup is stored (e.g., s3).Defaults to 'local'.
--to-databaseThe database connection to restore to (as defined in config/database.php).Defaults to your application's default database connection.
--latestA flag to restore the latest available backup without prompting the user.If omitted, the command runs in interactive mode.
--passwordThe password to decrypt an encrypted backup archive.Only required for encrypted backups.

Usage Examples

Interactive restore from the local disk:

# Starts an interactive prompt to select a backup from the 'local' disk
php artisan aaix:backup:db:restore

Automated restore of the latest backup from S3:

# Automatically finds and restores the latest backup from the 's3' disk
php artisan aaix:backup:db:restore --latest --from-disk=s3

Interactive restore of an encrypted backup to a specific database:

# Interactively select an encrypted backup from 's3' and restore it to the 'testing_db' connection
php artisan aaix:backup:db:restore --from-disk=s3 --to-database=testing_db --password="your-secret-password"