Postgres, Restic, and some env variables, all in a convenient alpine image
287
Take the postgresql image, add restic to it and finish it off with a bash script and some env variables and you get a nice way to back up arbitrary postgresql databases to a restic repo.
This image is backed by the git repo https://gitlab.com/hochri/restic_postgres_backup.
In order to support multiple versions of postgres, there are tags designating the used postgres versions (e.g. 13.0 or 14.0)
Configuration for DB and Restic can be achieved through these environment variables:
| Env Name | Description | Examples |
|---|---|---|
| DBHOST | Hostname of the postgresql. This corresponds to the container name of the DB-Container | e.g. postgresql |
| DBUSER | Username for the DB to be backed up. | |
| DBPASSWORD | Password for the DB to be backed up. | |
| DBNAME | Database name. | |
| DUMP | File name of the sql dump file. | backup.sql |
| RESTIC_REPOSITORY | Target Repository where the backup should be stored to. (Any type Restic supports) | |
| RESTIC_PASSWORD | Password to the given Restic Repository. | |
| UID | Numeric representation of the UID that should own the created dump and execute the restic backup. This is optional. If left empty, the backup will run as root. | e.g. 1000 |
There are no default values behind these variables, you have to provide all of them!
For the values and meanings of the RESTIC_* variables and other variables you may have to set check out the Restic Docs
This image has ssh/sftp installed to make use of sftp as repository targets. In order to make headless, Host Key Verification is disabled. Only use ssh/sftp servers that you really trust
You can set a full path for file as well however, working outside of /opt or /tmp will most likely cause problems with non-existing directories
You can use local repositores with restic as well. In this case you have to mount the container as well. Just make sure that DUMP and the repository don't occupy the same directory in the container.
This image is published on docker hub under hochri/restic_postgres_backup
Content type
Image
Digest
Size
13.4 MB
Last updated
over 5 years ago
docker pull hochri/restic_postgres_backup