ixnode/bash-db-dumper
Composer 安装命令:
composer require ixnode/bash-db-dumper
包简介
Bash DB Dumper
README 文档
README
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_URLMYSQLDUMP_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_TABLESMYSQLDUMP_TABLES_NO_DATAMYSQLDUMP_TABLES_ONLY_DATAMYSQLDUMP_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
| Variable | Description | Example |
|---|---|---|
MYSQLDUMP_DATABASE_URL |
Contains the database credentials. | mysql://user:pass@localhost:3306/db?serverVersion=8.0 |
MYSQLDUMP_IGNORED_TABLES |
Contains a comma-separated list of tables which are to be ignored by the dump command. Asterisk can be used to specify several tables at once. | table1,table2,cache_* |
MYSQLDUMP_FILTERED_TABLES |
Used to filter the content of tables. As an example only export data that is not deleted or is hidden (deleted = 0 AND hidden = 0). |
table3:"deleted = 0 AND hidden = 0",table4:"deleted = 0 AND hidden = 0" |
$MYSQLDUMP_FILTERED_TABLES_DELETED_HIDDEN |
A shortcut for MYSQLDUMP_FILTERED_TABLES with --where="deleted = 0 AND hidden = 0". Contains a comma-separated list of tables to be filtered. |
table3,table4 |
MYSQLDUMP_TABLES_NO_DATA |
Contains a comma-separated list of tables from which no data should be dumped. Asterisk can be used to specify several tables at once. | table5,table6_* |
MYSQLDUMP_TABLES_ONLY_DATA |
Contains a comma-separated list of tables from which no structure of tables should be dumped. Asterisk can be used to specify several tables at once. | table7,table8_* |
MYSQLDUMP_VIEWS |
Contains a comma-separated list of views. Views will be imported after the tables are imported. Asterisk can be used to specify several tables at once. | view1,view2_* |
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
ixnode/bash-db-dumper 适用场景与选型建议
ixnode/bash-db-dumper 是一款 基于 Shell 开发的 Composer 扩展包,目前已累计 797 次下载、GitHub Stars 达 1, 最近一次更新时间为 2023 年 01 月 28 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「database」 「fixtures」 「db」 「import」 「export」 「dumper」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 ixnode/bash-db-dumper 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ixnode/bash-db-dumper 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 ixnode/bash-db-dumper 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Dibi is Database Abstraction Library for PHP
Testing object factory for PHP
Testing object factory for PHP
Store your language lines in the database, yaml or other sources
A package for automatically encrypting and decrypting Eloquent attributes in Laravel 5.5+, based on configuration settings.
Plugin to compare fixtures with live DB tables
统计信息
- 总下载量: 797
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 12
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-01-28