kodeops / laravel-mysql-dumper
Dump and restore the contents of a MySQL database
Installs: 4 428
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 1
Open Issues: 0
Requires
- php: ^7.1.3|^8
- ifsnop/mysqldump-php: ^2.7
- spatie/laravel-package-tools: ^1.6.2
README
_ _ _____ ______ _______ _____ _____ _______
|____/ | | | \ |______ | | |_____] |______
| \_ |_____| |_____/ |______ |_____| | ______|
kodeops/laravel-mysql-dumper
Dump and restore the contents of a MySQL database.
Install
Add composer dependency
composer require kodeops/laravel-mysql-dumper
Add database connection settings to the environment file
The SOURCE
prefix indicates the database settings where the dump will be generated from:
MYSQL_DUMPER_DESTINATION_HOST=
MYSQL_DUMPER_DESTINATION_PORT=
MYSQL_DUMPER_DESTINATION_DATABASE=
MYSQL_DUMPER_DESTINATION_USERNAME=
MYSQL_DUMPER_DESTINATION_PASSWORD=
The DESTINATION
prefix indicates the database settings where the dump will be imported:
MYSQL_DUMPER_SOURCE_HOST=
MYSQL_DUMPER_SOURCE_PORT=
MYSQL_DUMPER_SOURCE_DATABASE=
MYSQL_DUMPER_SOURCE_USERNAME=
MYSQL_DUMPER_SOURCE_PASSWORD=
Example:
MYSQL_DUMPER_DESTINATION_HOST=127.0.0.1
MYSQL_DUMPER_DESTINATION_PORT=3306
MYSQL_DUMPER_DESTINATION_DATABASE=destination-database
MYSQL_DUMPER_DESTINATION_USERNAME=root
MYSQL_DUMPER_DESTINATION_PASSWORD=secret
MYSQL_DUMPER_SOURCE_HOST=127.0.0.1
MYSQL_DUMPER_SOURCE_PORT=3306
MYSQL_DUMPER_SOURCE_DATABASE=source-database
MYSQL_DUMPER_SOURCE_USERNAME=root
MYSQL_DUMPER_SOURCE_PASSWORD=secret
Using the command line
Cloning the source database to the destination database
php artisan mysql-dumper:clone
Exporting the source database to a file
php artisan mysql-dumper:export
Importing a dump file to the destination database
php artisan mysql-dumper:import /home/vagrant/app/storage/laravel-mysql-dumper/test.sql
Production safe
The command is not available in production environments unless you add the --force
option:
php artisan mysql-dumper:clone
Dump storage
All dumps are located in the laraval storage path in laravel-mysql-dumper
folder:
/home/vagrant/app/storage/laravel-mysql-dumper