kodeops/laravel-mysql-dumper

Dump and restore the contents of a MySQL database
5,220
Install
composer require kodeops/laravel-mysql-dumper
Latest Version:0.3.3
PHP:^7.1.3|^8
Laravel:10 – 13
License:MIT
Last Updated:Jun 30, 2022
Links: GitHub  ·  Packagist
Maintainer: kodeops
 _     _  _____  ______  _______  _____   _____  _______
 |____/  |     | |     \ |______ |     | |_____] |______
 |    \_ |_____| |_____/ |______ |_____| |       ______|
 

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

Related Packages

luiz-albertoni/dynamic-mysql-db-backup

Dynamic save mysql dumps to your specific Storage

4,154 0
guanguans/laravel-dump-sql

laravel 中轻松容易的输出完整的 SQL 语句。 - Easy output of complete SQL statemen...

40,322 36
xve/laravel-db-export

Laravel database export package with profile-based exclusions, anonymization, an...

2,102 0
weiyongsheng/laravel-performance

laravel performance and sql dump.

84 2
antennaio/laravel-codeception-dbdump

Create database dumps ready to be used with Codeception

1,515 6

Version History

Version Released PHP License
0.3.3 ^7.1.3|^8 MIT
0.3.2 ^7.1.3|^8 MIT
0.3.1 ^7.1.3 MIT
0.3 ^7.1.3 MIT
0.2 ^7.1.3 MIT