Loading...

About the DB CLI Builder

The mysql, psql, mysqldump, and pg_dump invocations you need during an incident are exactly the ones nobody remembers: which flag is the host, how to pass the password safely, what makes a dump restorable. This builder assembles connect, backup, and restore commands for MySQL and PostgreSQL from structured inputs.

It encodes the operational details that bite at 3 a.m.: pg_dump custom format versus plain SQL, --single-transaction for consistent InnoDB dumps without locking, and the right restore counterpart for each dump format.

Frequently asked questions

How do I pass database passwords without leaking them?

Never on the command line — ps and shell history expose it. For PostgreSQL use the PGPASSWORD env var or, better, ~/.pgpass (chmod 600). For MySQL use a ~/.my.cnf with credentials or mysql_config_editor. CI systems should inject credentials via secrets, never bake them into the command string.

Which pg_dump format should I use?

Custom format (-Fc) for almost everything: it is compressed, supports parallel restore (pg_restore -j), and allows selective table restore. Plain SQL format is only preferable when you need to read or edit the dump, or restore on a system without pg_restore. Directory format (-Fd) adds parallel dump for very large databases.

How do I dump a MySQL database without locking production tables?

mysqldump --single-transaction does a consistent snapshot read for InnoDB tables without global locks. Add --quick for large tables (streams rows instead of buffering). Caveats: it doesn't cover MyISAM tables, and schema changes during the dump can still break consistency — for serious workloads, dump from a replica.

Need this managed for you, not just automated?

We're also a hands-on DevOps consultancy — Kubernetes, CI/CD, and cloud infrastructure.

Explore Our Services