A Laravel database export console command.
tomshaw/laravel-database-export is a Laravel package for a laravel database export console command..
It currently has 1 GitHub stars and 609 downloads on Packagist (latest version v0.6.1).
Install it with composer require tomshaw/laravel-database-export.
Discover more Laravel packages by tomshaw
or browse all Laravel packages to compare alternatives.
Last updated
A Laravel console command that exports your database to a compressed, optionally AES-256 encrypted zip archive on any Laravel filesystem disk. Supports SQLite, MySQL, MariaDB, PostgreSQL and SQL Server.
MYSQL_PWD, PGPASSWORD and SQLCMDPASSWORD environment variables so they never appear in the process list.zip extension and the dump tool for your database (sqlite3, mysqldump, pg_dump or sqlcmd) on your PATH.You can install the package via composer:
composer require tomshaw/laravel-database-export
Optionally publish the configuration file:
php artisan vendor:publish --tag=database-export-config
Export the default database connection:
php artisan db:export
Export a specific connection:
php artisan db:export --connection=pgsql
Encrypt the archive with a custom password (defaults to the database password when omitted):
php artisan db:export --password=yourpassword
Archives are stored as exports/{connection}/{filename}-{timestamp}.zip on the configured disk.
The command implements Isolatable, so overlapping scheduled runs are prevented automatically:
Schedule::command('db:export', ['--isolated' => true])->daily();
| Key | Env variable | Default | Description |
| --- | --- | --- | --- |
| database-export.disk | BACKUP_DISK | local | Filesystem disk where archives are stored. |
| database-export.filename | BACKUP_FILENAME | export | Base filename; a timestamp is appended. |
| database-export.directory | BACKUP_DIRECTORY | exports | Directory on the disk; a per-connection subdirectory is added. |
| database-export.timeout | BACKUP_TIMEOUT | 3600 | Maximum seconds the dump process may run. |
| database-export.compression_level | BACKUP_COMPRESSION_LEVEL | 6 | Deflate compression level (0β9). |
| database-export.options | β | sensible defaults | Extra CLI options passed to the dump tool, per driver. |
For example, the default MySQL options produce consistent, complete dumps without table locks:
'options' => [
'mysql' => ['--single-transaction', '--routines', '--triggers', '--no-tablespaces'],
],
--password is provided.BACKUP DATABASE, which is executed by the database server itself β the server must have access to the local temporary directory, so this is intended for setups where the server runs on the same host.composer test
Run static analysis and formatting:
composer analyse
composer format
If you have any issues or questions, please open an issue on the GitHub repository.
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
The MIT License (MIT). See License File for more information.