kodeops/laravel-mysql-dumper

Dump and restore the contents of a MySQL database

0.3.3 2022-06-30 10:50 UTC

This package is auto-updated.

Last update: 2024-04-29 05:05:28 UTC


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