Laravel 5+ package for auto dump mysql database to local storage or to cloud
Laravel package for auto dump mysql database to local storage and auto upload to cloud like S3., (*1)
composer require lexuses/mysql-dump
For laravel below 5.5: add Lexuses\MysqlDump\MysqlDumpServiceProvider
to your app.php, (*2)
Run this in the command line:, (*3)
php artisan vendor:publish
Edit config/filesystems.php
and set local storage or use existing:, (*4)
'disks' => [ 'database' => [ 'driver' => 'local', 'root' => database_path(), ], ],
Edit config/mysql-dump.php
and set where to storage, dump name, folders name, max dumps for period., (*5)
Set mysqldump
command. By default it use --complete-insert
flag it means save only data not structure. Check official docs dev.mysql.com/doc/refman/5.7/en/mysqldump.html, (*6)
You can use it with docker. So you have to set mysql dump to:, (*7)
'mysqldump' => 'docker exec laradock_mysql_1 /usr/bin/mysqldump'
Don't forget to check name of you container., (*8)
Auto mode. Add command to Console/Kernel.php
, (*9)
protected function schedule(Schedule $schedule) { $schedule->command('mysql-dump:auto')->hourly(); }
Manual mode:, (*10)
php artisan mysql-dump:export
List of dumps:, (*11)
php artisan mysql-dump:list
Import dump:, (*12)
It will download the file if you save your dump in the cloud., (*13)
php artisan mysql-dump:import
Truncate:, (*14)
php artisan mysql-dump:truncate
Drop tables:, (*15)
php artisan mysql-dump:drop