From 893fbcf9ffeb6f48fff70c0c0996c955c52114f4 Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Thu, 14 Mar 2024 18:00:52 -0700 Subject: [PATCH] Add documentation about backing up containerized databases by configuring borgmatic to exec into a container to run a dump command. --- NEWS | 3 +++ docs/how-to/backup-your-databases.md | 30 ++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/NEWS b/NEWS index a71d5a0..3de30a3 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,8 @@ 1.8.10.dev0 * Fix handling of the NO_COLOR environment variable to ignore an empty value. + * Add documentation about backing up containerized databases by configuring borgmatic to exec into + a container to run a dump command: + https://torsion.org/borgmatic/docs/how-to/backup-your-databases/#containers 1.8.9 * #311: Add custom dump/restore command options for MySQL and MariaDB. diff --git a/docs/how-to/backup-your-databases.md b/docs/how-to/backup-your-databases.md index 64db6cf..dfb57cb 100644 --- a/docs/how-to/backup-your-databases.md +++ b/docs/how-to/backup-your-databases.md @@ -206,6 +206,36 @@ hooks: Alter the ports in these examples to suit your particular database system. +Normally, borgmatic dumps a database by running a database dump command (e.g. +`pg_dump`) on the host or wherever borgmatic is running, and this command +connects to your containerized database via the given `hostname` and `port`. +But if you don't have any database dump commands installed on your host and +you'd rather use the commands inside your database container itself, borgmatic +supports that too. Just configure borgmatic to `exec` into your container to +run the dump command. + +For instance, if using Docker and PostgreSQL, something like this might work: + +```yaml +hooks: + postgresql_databases: + - name: users + hostname: 127.0.0.1 + port: 5433 + username: postgres + password: trustsome1 + pg_dump_command: docker exec my_pg_container pg_dump +``` + +... where `my_pg_container` is the name of your database container. In this +example, you'd also need to set the `pg_restore_command` and `psql_command` +options. + +Similar command override options are available for (some of) the other +supported database types as well. See the [configuration +reference](https://torsion.org/borgmatic/docs/reference/configuration/) for +details. + ### No source directories