-
How-to guides
- π₯ Install borgmatic
- π Set up backups
- ποΈ Make per-application backups
- π Provide your passwords
- βοΈ Make backups redundant
- π Deal with very large backups
- π Inspect your backups
- π¨ Monitor your backups
- π€ Extract a backup
- ποΈ Backup your databases
- πΈ Snapshot your filesystems
- π§Ή Add preparation and cleanup steps
- πΎ Backup to a removable drive/server
- π§ Run arbitrary Borg commands
- π₯ Customize warnings/errors
- π¦ Upgrade borgmatic/Borg
- ποΈ Develop on borgmatic
-
Reference guides
- βοΈ Configuration
- π» Command-line
- π Source code
New in version 1.8.2 To backup
MariaDB with borgmatic, use the mariadb_databases: hook instead of
mysql_databases: as the MariaDB hook calls native MariaDB commands instead of
the deprecated MySQL ones. For instance:
mariadb_databases:
- name: comments
System databases
New in version 2.1.6 When dumping "all" databases, borgmatic excludes most data coming from MariaDB system databases, because much of it is populated on MariaDB startup and thus not restorable (or just unnecessary to backup). The system data that borgmatic does include in these dumps are: users, roles, grants, user-defined functions, and remote servers.
Within a Borg archive, you can find this data stored in a dump named mysqlβthe
name of the system table this data comes from. And if you'd like to dump this
data without having to dump "all" databases, then you can configure a database
named mysql in your borgmatic configuration. For example:
mariadb_databases:
- name: mysql
Even in this case though, only the subset of system data described above is included in the dump.
Prior to version 2.1.6 Dumps of
"all" databases excluded system databases and all of their data. Additionally,
explicitly dumping mysql was treated like any other databaseβand thus wasn't
easily restorable.
Full configuration
Here's an example configuration with all of the available options for this feature in the most recent version of borgmatic. If you're using an older version, some of these options may not work, and you should instead generate a sample configuration file specific to your borgmatic version.
# List of one or more MariaDB databases to dump before creating a
# backup, run once per configuration file. The database dumps are
# added to your source directories at runtime and streamed directly
# to Borg. Requires mariadb-dump/mariadb commands. See
# https://mariadb.com/kb/en/library/mysqldump/ for details.
mariadb_databases:
# Database name (required if using this hook). Or "all" to
# dump all databases on the host. Note that using this
# database hook implicitly enables read_special (see
# above) to support dump and restore streaming.
- name: users
# Database names to skip when dumping "all" databases.
# Ignored when the database name is not "all".
skip_names:
- cache
# Label to identify the database dump in the backup.
label: my_backup_label
# Container name/id to connect to. When specified the
# hostname is ignored. Requires docker/podman CLI.
container: debian_stable
# Container name/id to restore to. Defaults to the
# "container" option.
restore_container: restore_container
# Database hostname to connect to. Defaults to connecting
# via local Unix socket.
hostname: database.example.org
# Database hostname to restore to. Defaults to the
# "hostname" option.
restore_hostname: database.example.org
# Port to connect to. Defaults to 3306.
port: 3307
# Port to restore to. Defaults to the "port" option.
restore_port: 5433
# Path of a Unix socket to connect to instead of a remote
# hostname. Ignored when "hostname" is set and not
# "localhost". Defaults to "/run/mysqld/mysqld.sock".
socket_path: database.example.org
# Path of a Unix socket to connect to instead of a remote
# hostname. Ignored when "hostname" is set and not
# "localhost". Defaults to the "socket_path" option.
restore_socket_path: database.example.org
# Username with which to connect to the database. Defaults
# to the username of the current user. Supports the
# "{credential ...}" syntax.
username: dbuser
# Username with which to restore the database. Defaults to
# the "username" option. Supports the "{credential ...}"
# syntax.
restore_username: dbuser
# Password with which to connect to the database. Omitting
# a password will only work if MariaDB is configured to
# trust the configured username without a password.
# Supports the "{credential ...}" syntax.
password: trustsome1
# Password with which to connect to the restore database.
# Defaults to the "password" option. Supports the
# "{credential ...}" syntax.
restore_password: trustsome1
# How to transmit database passwords from borgmatic to the
# MariaDB client, one of:
# * "pipe": Securely transmit passwords via anonymous
# pipe. Only works if the database client is on the
# same host as borgmatic. (The server can be
# somewhere else.) This is the default value.
# * "environment": Transmit passwords via environment
# variable. Potentially less secure than a pipe, but
# necessary when the database client is elsewhere, e.g.
# when "mariadb_dump_command" is configured to "exec"
# into a container and run a client there.
password_transport:
# Whether to TLS-encrypt data transmitted between the
# client and server. The default varies based on the
# MariaDB version.
tls: false
# Whether to TLS-encrypt data transmitted between the
# client and restore server. The default varies based on
# the MariaDB version.
restore_tls: false
# Command to use instead of "mariadb-dump". But set any
# additional command-line flags in "options", not here.
# This command can be used to run a specific mariadb_dump
# version (e.g., one inside a running container). If you
# run it from within a container, make sure to mount the
# path in the "user_runtime_directory" option from the
# host into the container at the same location. Defaults
# to "mariadb-dump".
mariadb_dump_command: docker exec mariadb_container mariadb-dump
# Command to run instead of "mariadb". But set any
# additional command-line flags in "list_options" or
# "restore_options", not here. This command can be used to
# run a specific mariadb version (e.g., one inside a
# running container). Defaults to "mariadb".
mariadb_command: docker exec mariadb_container mariadb
# Database dump output format. Currently only "sql" is
# supported. Defaults to "sql" for a single database. Or,
# when database name is "all" and format is blank, dumps
# all databases to a single file. But if a format is
# specified with an "all" database name, dumps each
# database to a separate file of that format, allowing
# more convenient restores of individual databases.
format: directory
# Use the "--add-drop-database" flag with mariadb-dump,
# causing the database to be dropped right before restore.
# Defaults to true.
add_drop_database: false
# Additional mariadb-dump options to pass directly to the
# dump command, without performing any validation on them.
# See mariadb-dump documentation for details.
options: --skip-comments
# Additional options to pass directly to the mariadb
# command that lists available databases, without
# performing any validation on them. See mariadb command
# documentation for details.
list_options: --defaults-extra-file=mariadb.cnf
# Additional options to pass directly to the mariadb
# command that restores database dumps, without
# performing any validation on them. See mariadb command
# documentation for details.
restore_options: --defaults-extra-file=mariadb.cnf
Related documentation
Improve this documentation
Have an idea on how to make this documentation even better? Use our issue tracker to send your feedback!