π
-
How-to guides
- π₯ 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.4.9 To backup
MySQL with borgmatic, use the mysql_databases: hook. For instance:
mysql_databases:
- name: posts
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 MySQL 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 mysqldump/mysql commands. See
# https://dev.mysql.com/doc/refman/8.0/en/mysqldump.html for
# details.
mysql_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 MySQL 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
# MySQL 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 "mysql_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
# MySQL installation.
tls: false
# Whether to TLS-encrypt data transmitted between the
# client and restore server. The default varies based on
# the MySQL installation.
restore_tls: false
# Command to use instead of "mysqldump". But set any
# additional command-line flags in "options", not here.
# This command can be used to run a specific mysql_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 "mysqldump".
mysql_dump_command: docker exec mysql_container mysqldump
# Command to run instead of "mysql". But set any
# additional command-line flags in "list_options" or
# "restore_options", not here. This command can be used to
# run a specific mysql version (e.g., one inside a running
# container). Defaults to "mysql".
mysql_command: docker exec mysql_container mysql
# 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 mysqldump,
# causing the database to be dropped right before restore.
# Defaults to true.
add_drop_database: false
# Additional mysqldump options to pass directly to the
# dump command, without performing any validation on them.
# See mysqldump documentation for details.
options: --skip-comments
# Additional options to pass directly to the mysql
# command that lists available databases, without
# performing any validation on them. See mysql command
# documentation for details.
list_options: --defaults-extra-file=my.cnf
# Additional options to pass directly to the mysql
# command that restores database dumps, without
# performing any validation on them. See mysql command
# documentation for details.
restore_options: --defaults-extra-file=my.cnf
Improve this documentation
Have an idea on how to make this documentation even better? Use our issue tracker to send your feedback!