ixnode/bash-db-dumper

Bash DB Dumper

Installs: 518

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 1

Forks: 1

Open Issues: 0

Language:Shell

0.1.10 2023-10-12 10:11 UTC

This package is auto-updated.

Last update: 2024-12-12 12:57:30 UTC


README

Release PHP LICENSE

This tool helps you to dump db fixtures from given database and can import existing db fixtures. Credentials and configurations are read from an .env file.

Installation

Within a PHP project (composer)

composer require --dev ixnode/bash-db-dumper
vendor/bin/db-dumper -V
db-dumper 0.1.1 (2023-28-01 18:07:16) - Björn Hempel <bjoern@hempel.li>

Outside the project

git clone git@github.com:ixnode/bash-db-dumper.git && cd bash-db-dumper
bin/db-dumper -V
db-dumper 0.1.1 (2023-28-01 18:07:16) - Björn Hempel <bjoern@hempel.li>

Preparation

Add at least the following configuration variables to your .env file:

  • MYSQLDUMP_DATABASE_URL
  • MYSQLDUMP_IGNORED_TABLES
###> table-dumper (local docker settings) ###
MYSQLDUMP_DATABASE_URL=mysql://<db-user>:<db-pass>@<db-host>:<db-port>/<db-name>?serverVersion=<version>
MYSQLDUMP_IGNORED_TABLES=
###< table-dumper (local docker settings) ###

See .env.dist file for other examples and configuration variables like:

  • MYSQLDUMP_FILTERED_TABLES
  • MYSQLDUMP_TABLES_NO_DATA
  • MYSQLDUMP_TABLES_ONLY_DATA
  • MYSQLDUMP_VIEWS

MySQL dump settings: Views will be imported after importing all tables to be sure all needed tables are exists

Example: MYSQLDUMP_VIEWS=view_1,view_2

#=

Overview of configuration

Dump tables into db fixtures

Via composer

vendor/bin/db-dumper dump

Cloned project

bin/db-dumper dump

All dumps are then located in ./fixtures/db/*.sql.

Import existing db fixtures located in ./fixtures/db/*.sql into database

Via composer

vendor/bin/db-dumper import

Cloned project

bin/db-dumper import

Show help

Shows the parameters and arguments of the tool.

vendor/bin/db-dumper -h
db-dumper 0.1.1 (2023-28-01 18:07:16) - Björn Hempel <bjoern@hempel.li>

Usage: db-dumper [options...] dump
Usage: db-dumper [options...] import

 -e,    --env-path                    Contains the environment path (.env.local)

 -dcs,  --disable-column-statistics   Disable mysql column statistics


 -t,    --with-time                   Also outputs the time to each log entry (default: false).
 -v,    --verbose                     Set output to verbose (default: false).
 -c,    --color                       Colored output (default: false).
 -d,    --debug                       Set to debug mode. No longer performs any actions.
                                      Shows only the commands. (default: false).
 -l,    --print-log                   Print the log file
 -u,    --update-version              Shows this script with updated version read from VERSION
 -h,    --help                        Shows this help.
 -V,    --version                     Shows the version number.

Use debug mode

The command only shows the commands and does not execute them:

Via composer

vendor/bin/db-dumper dump -d
vendor/bin/db-dumper import -d

Cloned project

bin/db-dumper dump -d
bin/db-dumper import -d

Show last log

vendor/bin/db-dumper -l

Update version

vendor/bin/version-manager --patch
bin/db-dumper -u
rm bin/db-dumper && mv bin/db-dumper.tmp bin/db-dumper
vi CHANGELOG.md

License

This tool is licensed under the MIT License - see the LICENSE.md file for details