db:dump

Introduction

db:dump writes a SQL dump of the selected product’s MariaDB database. db:restore loads it back.

splent db:dump
Database dump created successfully: dump_splentdb_20260930_120000.sql

Without a name, the file is dump_<database>_YYYYMMDD_HHMMSS.sql in the current directory.


Choosing where it goes

splent db:dump backups/
splent db:dump backups/before-upgrade.sql

A directory, or a name ending in /, gets the generated name inside it. A name without an extension gets .sql. The directory must exist, or the command stops and writes nothing.


Compressing and pruning old dumps

splent db:dump backups/ --gzip --retention 7

--gzip writes a .sql.gz file. A name that already ends in .sql.gz compresses too.

--retention 7 keeps the 7 most recent dumps that share the new dump’s prefix in that directory, and deletes the rest. Each is reported as Pruned old dump <name>.

It only ever deletes files named <prefix>_YYYYMMDD_HHMMSS.sql[.gz]. The generated name’s prefix carries the database name, so one product never prunes another’s dumps. Recency comes from the timestamp in the name, and the dump just written is always kept.


Advanced

The dump runs mariadb-dump --single-transaction --quick --default-character-set=utf8mb4, or mysqldump. It replaces the target only when it succeeds, so a failed dump never truncates an existing file.


Reference

Options

Option Description
FILENAME Optional. The file or directory to write to
--gzip Compress with gzip, as .sql.gz
--retention N Keep only the N most recent timestamped dumps with the same prefix. 0, the default, keeps everything

Errors

Message What to do
❌ Missing env vars: ... Run splent product:env --merge --dev to bring the MARIADB_* variables into docker/.env
Error: Directory '<dir>' does not exist. Create it first or choose another path. Create the directory, or pick another
Error: Dump is only N bytes (minimum 1024). ... The connection dropped mid-dump. Run it again

Requirements

  • A selected product. Without one it prints No product selected. Run: splent product:select <name> and exits 1.
  • A reachable database.
  • mariadb-dump or mysqldump where the command runs. The CLI image and the production image install mariadb-client, which provides both.

Back to top

splent. Distributed by an LGPL license v3. Contact us: drorganvidez@us.es