dbScriptAllDatabases
1. Help
Command: bin/dbScriptAllDatabases --help
SYNOPSIS:
Allows to execute a script on each database of specified mysql server.
USAGE: dbScriptAllDatabases [OPTIONS] [ARGUMENTS]
USAGE: dbScriptAllDatabases [--jobs|-j <jobsCount>] [--bar|-b]
[--from-dsn|-f <dsn>] [--help|-h] [--config]
[--bash-framework-config <bash-framework-config>] [--verbose|-v] [-vv] [-vvv]
[--log-level <log-level>] [--log-file <log-file>]
[--display-level <display-level>] [--no-color] [--theme <theme>] [--version]
[--quiet|-q] [--database <dbName>] [--output|-o <outputDirectory>]
[--log-format|-l <logFormat>]
ARGUMENTS:
scriptToExecute {single} (mandatory) The script that will be executed on each databases.
[scriptArguments {list} (optional)] Optional parameters to pass to the script.
JOB OPTIONS:
--jobs, -j <jobsCount> {single}
The number of databases to query in parallel.
Default value: 1
--bar, -b {single}
Show progress as a progress bar. In the bar is shown: % of jobs
completed, estimated seconds left, and number of jobs started.
SOURCE OPTIONS:
--from-dsn, -f <dsn> {single}
Target mysql server.
GLOBAL OPTIONS:
--help, -h {single}
Displays this command help
--config {single}
Displays configuration
--bash-framework-config <bash-framework-config> {single}
Use alternate bash framework configuration.
--verbose, -v {single}
Info level verbose mode (alias of --display-level INFO)
-vv {single}
Debug level verbose mode (alias of --display-level DEBUG)
-vvv {single}
Trace level verbose mode (alias of --display-level TRACE)
--log-level <log-level> {single}
Set log level
Possible values:
- OFF
- ERR
- ERROR
- WARN
- WARNING
- INFO
- DEBUG
- TRACE
Default value: OFF
--log-file <log-file> {single}
Set log file
Default value: /logs/bash.log
--display-level <display-level> {single}
Set display level
Possible values:
- OFF
- ERR
- ERROR
- WARN
- WARNING
- INFO
- DEBUG
- TRACE
Default value: INFO
--no-color {single}
Produce monochrome output. alias of --theme noColor.
--theme <theme> {single}
Choose color theme - default-force means colors will be produced even if
command is piped.
Possible values:
- default
- default-force
- noColor
Default value: default
--version {single}
Print version information and quit.
--quiet, -q {single}
Quiet mode, doesn't display any output.
SCRIPTS OPTIONS:
--database <dbName> {list} (optional)
If provided will check only databases specified,
otherwise script will be executed on all dbs of mysql server.
--output, -o <outputDirectory> {single}
Output directory, see log-format option.
--log-format, -l <logFormat> {single}
If output dir provided, will log each db result to log file.
Possible values:
- none
- log
Default value: none
DESCRIPTION:
Data Source Name (DSN)
Default dsn directory:
/bash/conf/dsn
User dsn directory:
/home/www-data/.bash-tools/dsn
Allows to override dsn defined in "Default dsn directory"
List of available dsn:
- default.local
- default.remote
- localhost-root
SCRIPTS
Default scripts directory:
/bash/conf/dbScripts
User scripts directory:
/home/www-data/.bash-tools/dbScripts
Allows to override queries defined in 'Default scripts directory'
List of available scripts:
NOTE:
the use of output, log-format, verbose options highly depends on the script used
EXAMPLES: script conf/dbScripts/extractData.sh
1. executes query databaseSize (see conf/dbQueries/databaseSize.sql) on each db and log the result in log file in default output dir, call it using
/bash/bin/dbScriptAllDatabases -j 10 extractData databaseSize
2. executes query databaseSize on each db and display the result on stdout (2>/dev/null hides information messages)
/bash/bin/dbScriptAllDatabases -j 10 --log-format none extractData databaseSize
3. use --verbose to get some debug information
/bash/bin/dbScriptAllDatabases -j 10 --log-format none --verbose extractData databaseSize
USE CASES:
you can use this script in order to check that each db model conforms with your ORM schema
simply create a new script in conf/dbQueries that will call your orm schema checker
update multiple db at once (simple to complex update script)
VERSION: 3.0
AUTHOR: [François Chastanet](https://github.com/fchastanet)
SOURCE FILE: https://github.com/fchastanet/bash-tools-framework/tree/master/src/_binaries/Database/dbScriptAllDatabases/dbScriptAllDatabases-binary.yaml
LICENSE: MIT License
Copyright (c) 2020-now François Chastanet
2. Usage
Allow to execute a script on each database of specified mysql server
bin/dbScriptAllDatabases -d localhost-root dbCheckStructOneDatabase
or specified db only
bin/dbScriptAllDatabases -d localhost-root dbCheckStructOneDatabase db
launch script in parallel on multiple db at once
bin/dbScriptAllDatabases --jobs 10 -d localhost-root dbCheckStructOneDatabase