File tree Expand file tree Collapse file tree 4 files changed +11
-0
lines changed Expand file tree Collapse file tree 4 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -51,6 +51,7 @@ services:
51
51
# - POSTGRES_PASSWORD_FILE=/run/secrets/db_password <-- alternative for POSTGRES_PASSWORD (to use with docker secrets)
52
52
- POSTGRES_EXTRA_OPTS=-Z1 --schema=public --blobs
53
53
- SCHEDULE=@daily
54
+ - BACKUP_ON_START=TRUE
54
55
- BACKUP_KEEP_DAYS=7
55
56
- BACKUP_KEEP_WEEKS=4
56
57
- BACKUP_KEEP_MONTHS=6
@@ -75,6 +76,7 @@ Most variables are the same as in the [official postgres image](https://hub.dock
75
76
|--|--|
76
77
| BACKUP_DIR | Directory to save the backup at. Defaults to `/backups`. |
77
78
| BACKUP_SUFFIX | Filename suffix to save the backup. Defaults to `.sql.gz`. |
79
+ | BACKUP_ON_START | If set to `TRUE` performs an backup on each container start or restart. Defaults to `FALSE`. |
78
80
| BACKUP_KEEP_DAYS | Number of daily backups to keep before removal. Defaults to `7`. |
79
81
| BACKUP_KEEP_WEEKS | Number of weekly backups to keep before removal. Defaults to `4`. |
80
82
| BACKUP_KEEP_MONTHS | Number of monthly backups to keep before removal. Defaults to `6`. |
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ ENV POSTGRES_DB="**None**" \
21
21
POSTGRES_EXTRA_OPTS="-Z1" \
22
22
POSTGRES_CLUSTER="FALSE" \
23
23
SCHEDULE="@daily" \
24
+ BACKUP_ON_START="FALSE" \
24
25
BACKUP_DIR="/backups" \
25
26
BACKUP_SUFFIX=".sql.gz" \
26
27
BACKUP_LATEST_TYPE="symlink" \
Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ ENV POSTGRES_DB="**None**" \
35
35
POSTGRES_EXTRA_OPTS="-Z1" \
36
36
POSTGRES_CLUSTER="FALSE" \
37
37
SCHEDULE="@daily" \
38
+ BACKUP_ON_START="FALSE" \
38
39
BACKUP_DIR="/backups" \
39
40
BACKUP_SUFFIX=".sql.gz" \
40
41
BACKUP_LATEST_TYPE="symlink" \
Original file line number Diff line number Diff line change @@ -4,4 +4,11 @@ set -Eeo pipefail
4
4
# Prevalidate configuration (don't source)
5
5
/env.sh
6
6
7
+ # Initial background backup
8
+ if [ " ${BACKUP_ON_START} " = " TRUE" ]; then
9
+ echo " Launching an startup backup as a background job..."
10
+ /backup.sh &
11
+ fi
12
+
13
+ echo " Starting go-cron ($SCHEDULE )..."
7
14
exec /usr/local/bin/go-cron -s " $SCHEDULE " -p " $HEALTHCHECK_PORT " -- /backup.sh
You can’t perform that action at this time.
0 commit comments