Easiest way to dump MySQL/MariaDB offline

After years of doing so manually (there are a couple how-to’s here) I finally got around to automating the process. Have a look:

https://github.com/djamps/mariadump

# git clone https://github.com/djamps/mariadump.git
# cd mariadump/
# ./run.sh
Usage: ./run.sh [options] [--run | --list]

Options:
--data-dir Specify data directory (default: ./mysql).
--dumps-dir Specify dumps output directory (default: ./dumps).
--version Specify MariaDB Docker tag (e.g., 10.3). If omitted, auto-detects from data.
--recovery <0-6> Set InnoDB force recovery level (default: 0). Higher values for corrupt data.
--database Dump only a specific database (overrides full dumps and --table).
--skip-tables <t1,t2> Comma-separated tables to skip in the database (only with --database; for corrupt tables).
--table Dump only a specific database table (overrides full dumps and --database).
--mysqldump-args "arg1 arg2" Pass raw arguments to mysqldump (e.g., "--skip-add-drop-table --skip-add-locks"; applies to all dumps).
--mariadb-args "arg1 arg2" Pass raw arguments to mariadb server (e.g., "--innodb-buffer-pool-size=1G"; appended to mysqld).
--nocompress Output plain .sql files instead of .sql.gz (applies to all dumps).
--list List databases or tables (with --database) instead of dumping; rejects --table and --run.

Examples:
./run.sh --run # Auto-detect version, recovery 0, all databases
./run.sh --recovery 4 --run # Auto-detect version, recovery 4, all databases
./run.sh --version 10.3 --run # Version 10.3, recovery 0, all databases
./run.sh --database mydb --run # Auto-detect version, recovery 0, only mydb
./run.sh --database mydb --skip-tables bad1,bad2 --run # Auto-detect, recovery 0, mydb skipping bad1/bad2
./run.sh --table mydb.mytable --run # Auto-detect version, recovery 0, only mydb.mytable
./run.sh --version 10.3 --recovery 2 --database mydb --skip-tables bad1 --mysqldump-args "--skip-add-drop-table" --mariadb-args "--innodb-buffer-pool-size=1G" --nocompress --run # All relevant options
./run.sh --data-dir /path/to/data --dumps-dir /path/to/dumps --run # Custom directories
./run.sh --list # List all non-system databases
./run.sh --database mydb --list # List tables in mydb

No Comments.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>