Skip to content

CLI Reference

Complete command line reference for db-sync-tool.

Basic Usage

bash
db_sync_tool [OPTIONS] [ORIGIN] [TARGET]

Arguments

ArgumentDescription
ORIGINOrigin database defined in host file or auto-discovery
TARGETTarget database defined in host file or auto-discovery

Configuration Options

OptionShortDescription
--config-file-fPath to configuration file
--host-file-oUsing an additional hosts file
--log-file-lFile path for creating an additional log file
--json-log-jlUse JSON format for log file output (structured logging)

Output Options

OptionShortDescription
--verbose-vEnable verbose output (-v) or debug (-vv)
--mute-mMute console output
--quiet-qSuppress all output except errors
--outputOutput format: interactive, ci, json, quiet

Execution Options

OptionShortDescription
--yes-ySkip user confirmation for database import
--dry-run-drTesting without running export, transfer, or import
--reverse-rReverse origin and target hosts
--force-password-fpwForce password user query

Database Dump Options

OptionShortDescription
--import-file-iImport database from a specific file dump
--dump-name-dnSet a specific dump file name
--keep-dump-kdSkip import and save dump in the given directory
--clear-database-cdDrop all tables before importing
--tables-taSpecific tables to export (e.g., --tables=t1,t2)
--where-wWHERE clause for partial sync
--additional-mysqldump-options-amoAdditional mysqldump options

Framework Options

OptionShortDescription
--type-tFramework type: TYPO3, Symfony, Drupal, WordPress, Laravel

Transfer Options

OptionShortDescription
--use-rsync-urUse rsync as transfer method
--use-rsync-options-uroAdditional rsync options

File Transfer Options

OptionShortDescription
--with-files-wfEnable file synchronization (requires 'files' section in config)
--files-only-foSync only files, skip database synchronization

Origin Client Options

OptionShortDescription
--origin-path-opPath to database credential file
--origin-name-onProviding a name for the origin system
--origin-host-ohSSH host to origin system
--origin-user-ouSSH user for origin system
--origin-password-opwSSH password for origin system
--origin-key-okFile path to SSH key for origin system
--origin-port-opoSSH port for origin system
--origin-dump-dir-oddDirectory path for database dump file on origin
--origin-keep-dumps-okdKeep dump file count for origin system

Origin Database Options

OptionShortDescription
--origin-db-name-odnDatabase name for origin system
--origin-db-host-odhDatabase host for origin system
--origin-db-user-oduDatabase user for origin system
--origin-db-password-odpwDatabase password for origin system
--origin-db-port-odpoDatabase port for origin system

Target Client Options

OptionShortDescription
--target-path-tpPath to database credential file
--target-name-tnProviding a name for the target system
--target-host-thSSH host to target system
--target-user-tuSSH user for target system
--target-password-tpwSSH password for target system
--target-key-tkFile path to SSH key for target system
--target-port-tpoSSH port for target system
--target-dump-dir-tddDirectory path for database dump file on target
--target-keep-dumps-tkdKeep dump file count for target system
--target-after-dump-tadAdditional dump file to insert after regular import

Target Database Options

OptionShortDescription
--target-db-name-tdnDatabase name for target system
--target-db-host-tdhDatabase host for target system
--target-db-user-tduDatabase user for target system
--target-db-password-tdpwDatabase password for target system
--target-db-port-tdpoDatabase port for target system

Other Options

OptionDescription
--install-completionInstall shell completion for the current shell
--show-completionShow completion for the current shell
--versionShow version and exit
--helpShow help message and exit

Examples

Basic Sync with Config File

bash
db_sync_tool -f config.yaml

Auto-Discovery with Host Names

bash
db_sync_tool production local

Verbose Dry Run

bash
db_sync_tool -f config.yaml -v --dry-run

Skip Confirmation

bash
db_sync_tool -f config.yaml -y

Import from Dump File

bash
db_sync_tool -f config.yaml -i /path/to/dump.sql

Keep Dump Without Import

bash
db_sync_tool -f config.yaml --keep-dump /var/backups/

Sync Specific Tables

bash
db_sync_tool -f config.yaml --tables=users,orders

Partial Sync with WHERE Clause

bash
db_sync_tool -f config.yaml --tables=orders --where="created_at > '2024-01-01'"

Reverse Origin and Target

bash
db_sync_tool -f config.yaml --reverse

Clear Database Before Import

bash
db_sync_tool -f config.yaml --clear-database

Sync with Files

bash
db_sync_tool -f config.yaml --with-files

Sync Only Files (Skip Database)

bash
db_sync_tool -f config.yaml --files-only

Use Rsync Transfer

bash
db_sync_tool -f config.yaml --use-rsync

CI/CD Mode (No Prompts)

bash
db_sync_tool -f config.yaml -y --output=ci

JSON Logging

bash
db_sync_tool -f config.yaml -l /var/log/sync.log --json-log

Debug Mode

bash
db_sync_tool -f config.yaml -vv

Shell Completion

Install shell completion for your shell:

bash
# Install
db_sync_tool --install-completion

# Show completion script
db_sync_tool --show-completion

Supported shells: bash, zsh, fish, PowerShell

Environment Variables

VariableDescription
DB_SYNC_TOOL_CONFIGDefault config file path
SSH_AUTH_SOCKSSH agent socket for key-based auth

Exit Codes

CodeDescription
0Success
1General error
2Configuration error
3Connection error
4Database error

Released under the MIT License.