Updated readme.md

Update docker build files
This commit is contained in:
atcommander
2022-06-23 21:05:59 +00:00
committed by Pau Rodriguez-Estivill
parent d1793740b3
commit 3cf2b9bdb3
3 changed files with 53 additions and 36 deletions
+37 -28
View File
@@ -46,9 +46,14 @@ services:
# - POSTGRES_PASSWORD_FILE=/run/secrets/db_password <-- alternative for POSTGRES_PASSWORD (to use with docker secrets) # - POSTGRES_PASSWORD_FILE=/run/secrets/db_password <-- alternative for POSTGRES_PASSWORD (to use with docker secrets)
- POSTGRES_EXTRA_OPTS=-Z6 --schema=public --blobs - POSTGRES_EXTRA_OPTS=-Z6 --schema=public --blobs
- SCHEDULE=@daily - SCHEDULE=@daily
- BACKUP_KEEP_DAYS=7 - BACKUP_KEEP_DAYS="2"
- BACKUP_KEEP_WEEKS=4 - BACKUP_DELETE_DAYS=false
- BACKUP_KEEP_MONTHS=6 - BACKUP_KEEP_WEEKS="0"
- BACKUP_DELETE_WEEKS=false
- BACKUP_KEEP_MONTHS="0"
- BACKUP_DELETE_MONTHS=false
- BACKUP_MONTH_DAY="01"
- BACKUP_WEEK_DAY="Sunday"
- HEALTHCHECK_PORT=8080 - HEALTHCHECK_PORT=8080
``` ```
@@ -66,37 +71,41 @@ mkdir -p /var/opt/pgbackups && chown -R 70:70 /var/opt/pgbackups
Most variables are the same as in the [official postgres image](https://hub.docker.com/_/postgres/). Most variables are the same as in the [official postgres image](https://hub.docker.com/_/postgres/).
| env variable | description | | env variable | description |
|--|--| | ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| BACKUP_DIR | Directory to save the backup at. Defaults to `/backups`. | | BACKUP_DIR | Directory to save the backup at. Defaults to `/backups`. |
| BACKUP_SUFFIX | Filename suffix to save the backup. Defaults to `.sql.gz`. | | BACKUP_SUFFIX | Filename suffix to save the backup. Defaults to `.sql.gz`. |
| BACKUP_KEEP_DAYS | Number of daily backups to keep before removal. Defaults to `7`. | | BACKUP_KEEP_DAYS | Number of daily backups to keep before removal. Defaults to `7`. |
| BACKUP_KEEP_WEEKS | Number of weekly backups to keep before removal. Defaults to `4`. | | BACKUP_DELETE_DAYS | Whether the daily backups are deleted. Defaults to `true`. |
| BACKUP_KEEP_MONTHS | Number of monthly backups to keep before removal. Defaults to `6`. | | BACKUP_KEEP_WEEKS | Number of weekly backups to keep before removal. Defaults to `4`. |
| BACKUP_KEEP_MINS | Number of minutes for `last` folder backups to keep before removal. Defaults to `1440`. | | BACKUP_DELETE_WEEKS | Whether the weekly backups are deleted. Defaults to `true`. |
| HEALTHCHECK_PORT | Port listening for cron-schedule health check. Defaults to `8080`. | | BACKUP_KEEP_MONTHS | Number of monthly backups to keep before removal. Defaults to `6`. |
| POSTGRES_DB | Comma or space separated list of postgres databases to backup. Required. | | BACKUP_DELETE_MONTHS | Whether the monthly backups are deleted. Defaults to `true`. |
| POSTGRES_DB_FILE | Alternative to POSTGRES_DB, but with one database per line, for usage with docker secrets. | | BACKUP_MONTH_DAY | What day of the month the monthly backup will be taken. Defaults to `01`. |
| POSTGRES_EXTRA_OPTS | Additional [options](https://www.postgresql.org/docs/12/app-pgdump.html#PG-DUMP-OPTIONS) for `pg_dump` (or `pg_dumpall` [options](https://www.postgresql.org/docs/12/app-pg-dumpall.html#id-1.9.4.13.6) if POSTGRES_CLUSTER is set). Defaults to `-Z6`. | | BACKUP_WEEK_DAY | What day of the week the weekly backup will be taken. Defaults to `Sunday`. |
| POSTGRES_CLUSTER | Set to `TRUE` in order to use `pg_dumpall` instead. Also set POSTGRES_EXTRA_OPTS to any value or empty since the default value is not compatible with `pg_dumpall`. | | HEALTHCHECK_PORT | Port listening for cron-schedule health check. Defaults to `8080`. |
| POSTGRES_HOST | Postgres connection parameter; postgres host to connect to. Required. | | POSTGRES_DB | Comma or space separated list of postgres databases to backup. Required. |
| POSTGRES_PASSWORD | Postgres connection parameter; postgres password to connect with. Required. | | POSTGRES_DB_FILE | Alternative to POSTGRES_DB, but with one database per line, for usage with docker secrets. |
| POSTGRES_PASSWORD_FILE | Alternative to POSTGRES_PASSWORD, for usage with docker secrets. | | POSTGRES_EXTRA_OPTS | Additional [options](https://www.postgresql.org/docs/12/app-pgdump.html#PG-DUMP-OPTIONS) for `pg_dump` (or `pg_dumpall` [options](https://www.postgresql.org/docs/12/app-pg-dumpall.html#id-1.9.4.13.6) if POSTGRES_CLUSTER is set). Defaults to `-Z6`. |
| POSTGRES_PASSFILE_STORE | Alternative to POSTGRES_PASSWORD in [passfile format](https://www.postgresql.org/docs/12/libpq-pgpass.html#LIBPQ-PGPASS), for usage with postgres clusters. | | POSTGRES_CLUSTER | Set to `TRUE` in order to use `pg_dumpall` instead. Also set POSTGRES_EXTRA_OPTS to any value or empty since the default value is not compatible with `pg_dumpall`. |
| POSTGRES_PORT | Postgres connection parameter; postgres port to connect to. Defaults to `5432`. | | POSTGRES_HOST | Postgres connection parameter; postgres host to connect to. Required. |
| POSTGRES_USER | Postgres connection parameter; postgres user to connect with. Required. | | POSTGRES_PASSWORD | Postgres connection parameter; postgres password to connect with. Required. |
| POSTGRES_USER_FILE | Alternative to POSTGRES_USER, for usage with docker secrets. | | POSTGRES_PASSWORD_FILE | Alternative to POSTGRES_PASSWORD, for usage with docker secrets. |
| SCHEDULE | [Cron-schedule](http://godoc.org/github.com/robfig/cron#hdr-Predefined_schedules) specifying the interval between postgres backups. Defaults to `@daily`. | | POSTGRES_PASSFILE_STORE | Alternative to POSTGRES_PASSWORD in [passfile format](https://www.postgresql.org/docs/12/libpq-pgpass.html#LIBPQ-PGPASS), for usage with postgres clusters. |
| TZ | [POSIX TZ variable](https://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html) specifying the timezone used to evaluate SCHEDULE cron (example "Europe/Paris"). | | POSTGRES_PORT | Postgres connection parameter; postgres port to connect to. Defaults to `5432`. |
| POSTGRES_USER | Postgres connection parameter; postgres user to connect with. Required. |
| POSTGRES_USER_FILE | Alternative to POSTGRES_USER, for usage with docker secrets. |
| SCHEDULE | [Cron-schedule](http://godoc.org/github.com/robfig/cron#hdr-Predefined_schedules) specifying the interval between postgres backups. Defaults to `@daily`. |
| TZ | [POSIX TZ variable](https://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html) specifying the timezone used to evaluate SCHEDULE cron (example "Europe/Paris"). |
#### Special Environment Variables #### Special Environment Variables
This variables are not intended to be used for normal deployment operations: This variables are not intended to be used for normal deployment operations:
| env variable | description | | env variable | description |
|--|--| | --------------------------- | -------------------------------------------------- |
| POSTGRES_PORT_5432_TCP_ADDR | Sets the POSTGRES_HOST when the latter is not set. | | POSTGRES_PORT_5432_TCP_ADDR | Sets the POSTGRES_HOST when the latter is not set. |
| POSTGRES_PORT_5432_TCP_PORT | Sets POSTGRES_PORT when POSTGRES_HOST is not set. | | POSTGRES_PORT_5432_TCP_PORT | Sets POSTGRES_PORT when POSTGRES_HOST is not set. |
### Manual Backups ### Manual Backups
+8 -4
View File
@@ -23,10 +23,14 @@ ENV POSTGRES_DB="**None**" \
SCHEDULE="@daily" \ SCHEDULE="@daily" \
BACKUP_DIR="/backups" \ BACKUP_DIR="/backups" \
BACKUP_SUFFIX=".sql.gz" \ BACKUP_SUFFIX=".sql.gz" \
BACKUP_KEEP_DAYS=7 \ BACKUP_KEEP_DAYS="7" \
BACKUP_KEEP_WEEKS=4 \ BACKUP_DELETE_DAYS=true \
BACKUP_KEEP_MONTHS=6 \ BACKUP_KEEP_WEEKS="4" \
BACKUP_KEEP_MINS=1440 \ BACKUP_DELETE_WEEKS=true \
BACKUP_KEEP_MONTHS="6" \
BACKUP_DELETE_MONTHS=true \
BACKUP_MONTH_DAY="01" \
BACKUP_WEEK_DAY="Sunday" \
HEALTHCHECK_PORT=8080 HEALTHCHECK_PORT=8080
COPY backup.sh /backup.sh COPY backup.sh /backup.sh
+8 -4
View File
@@ -38,10 +38,14 @@ ENV POSTGRES_DB="**None**" \
SCHEDULE="@daily" \ SCHEDULE="@daily" \
BACKUP_DIR="/backups" \ BACKUP_DIR="/backups" \
BACKUP_SUFFIX=".sql.gz" \ BACKUP_SUFFIX=".sql.gz" \
BACKUP_KEEP_DAYS=7 \ BACKUP_KEEP_DAYS="7" \
BACKUP_KEEP_WEEKS=4 \ BACKUP_DELETE_DAYS=true \
BACKUP_KEEP_MONTHS=6 \ BACKUP_KEEP_WEEKS="4" \
BACKUP_KEEP_MINS=1440 \ BACKUP_DELETE_WEEKS=true \
BACKUP_KEEP_MONTHS="6" \
BACKUP_DELETE_MONTHS=true \
BACKUP_MONTH_DAY="01" \
BACKUP_WEEK_DAY="Sunday" \
HEALTHCHECK_PORT=8080 HEALTHCHECK_PORT=8080
COPY backup.sh /backup.sh COPY backup.sh /backup.sh