diff --git a/NEWS b/NEWS index a71d5a02..3de30a32 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 64db6cfd..dfb57cbb 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