1- # pgdump-gcs
1+ # Postgres backup container for DB Operator
22
3- Small docker container for creating a backup of a psql database and upload the dump to an external storage using rclone.
3+ Small docker container for creating a backup of a psql database and uploading it to an external storage using rclone.
4+
5+ Every backup is uploaded twice, once with a ** timestamp** and once as ** latest** . So you can always download the latest backup.
6+
7+ There is no clean-up logic, please take care of old backups using external tools, for example bucket retention policies.
8+
9+ ## How to restore
10+
11+ This script is simply taking a database backup using ` pg_dump ` , you can restore it by setting env variables and running the following command:
12+
13+ ``` shell
14+ $ export PGHOST=< Database host >
15+ $ export PGPORT=< Database port >
16+ $ export PGUSER=< Admin user>
17+ $ export PGDATABASE=postgres
18+ $ export PGPASSWORD=< Admin password >
19+ $ pg_restore --no-owne:wr --no-privileges -d < Target database > --role < Target username > -Fc < Backup file path> --clean
20+ ```
421
522## How to use
6- TO BE DONE ...
723
8- ## monitoring
24+ This container is supposed to be used by the DB Operator for setting up backup CronJobs.
25+
26+ To backup a postgres database using this container you need to pass env variables for ` pg_dump ` and for ` rclone ` :
27+
28+ ** pg_dump** variables:
29+
30+ - ** DB_NAME** : A name of a database to back up
31+ - ** DB_HOST** : A database server host
32+ - ** DB_PASSWORD_FILE** : A path to a file with a database password (file must be mounted to the container)
33+ - ** DB_USER** : User that should perform the backup
34+
35+ ** rclone** variables:
36+
37+ - ** STORAGE_BUCKET** : A name of a bucket/directory that should be used for uploading the backup
38+
39+ For the rest, please check here: < https://rclone.org/docs/#environment-variables > .
40+
41+ The backend name is hardcoded to 'storage', so your env vars should be prefixed by ` RCLONE_CONFIG_STORAGE_ `
42+
43+ ## Monitoring
944
1045Simple curl pushing some basic parameter to a prometheus push gateway.
1146
@@ -15,6 +50,6 @@ Simple curl pushing some basic parameter to a prometheus push gateway.
1550* size
1651
1752### labels
18- * job = pgdump-gcs
53+ * job = pgdump-rclone
1954* source_type = postgresql
2055* source_name = ` ${DB_NAME} `
0 commit comments