mirror of
https://github.com/prodrigestivill/docker-postgres-backup-local.git
synced 2026-07-03 08:48:10 +00:00
@@ -95,6 +95,9 @@ Most variables are the same as in the [official postgres image](https://hub.dock
|
|||||||
| SCHEDULE | [Cron-schedule](http://godoc.org/github.com/robfig/cron#hdr-Predefined_schedules) specifying the interval between postgres backups. Defaults to `@daily`. |
|
| 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"). |
|
| 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"). |
|
||||||
| WEBHOOK_URL | URL to be called after an error or after a successful backup (POST with a JSON payload, check `hooks/00-webhook` file for more info). Default disabled. |
|
| WEBHOOK_URL | URL to be called after an error or after a successful backup (POST with a JSON payload, check `hooks/00-webhook` file for more info). Default disabled. |
|
||||||
|
| WEBHOOK_ERROR_URL | URL to be called in case backup fails. Default disabled. |
|
||||||
|
| WEBHOOK_PRE_BACKUP_URL | URL to be called when backup starts. Default disabled. |
|
||||||
|
| WEBHOOK_POST_BACKUP_URL | URL to be called when backup completes successfully. Default disabled. |
|
||||||
| WEBHOOK_EXTRA_ARGS | Extra arguments for the `curl` execution in the webhook (check `hooks/00-webhook` file for more info). |
|
| WEBHOOK_EXTRA_ARGS | Extra arguments for the `curl` execution in the webhook (check `hooks/00-webhook` file for more info). |
|
||||||
|
|
||||||
#### Special Environment Variables
|
#### Special Environment Variables
|
||||||
|
|||||||
@@ -30,6 +30,9 @@ ENV POSTGRES_DB="**None**" \
|
|||||||
BACKUP_KEEP_MINS=1440 \
|
BACKUP_KEEP_MINS=1440 \
|
||||||
HEALTHCHECK_PORT=8080 \
|
HEALTHCHECK_PORT=8080 \
|
||||||
WEBHOOK_URL="**None**" \
|
WEBHOOK_URL="**None**" \
|
||||||
|
WEBHOOK_ERROR_URL="**None**" \
|
||||||
|
WEBHOOK_PRE_BACKUP_URL="**None**" \
|
||||||
|
WEBHOOK_POST_BACKUP_URL="**None**" \
|
||||||
WEBHOOK_EXTRA_ARGS=""
|
WEBHOOK_EXTRA_ARGS=""
|
||||||
|
|
||||||
COPY hooks /hooks
|
COPY hooks /hooks
|
||||||
|
|||||||
@@ -44,6 +44,9 @@ ENV POSTGRES_DB="**None**" \
|
|||||||
BACKUP_KEEP_MINS=1440 \
|
BACKUP_KEEP_MINS=1440 \
|
||||||
HEALTHCHECK_PORT=8080 \
|
HEALTHCHECK_PORT=8080 \
|
||||||
WEBHOOK_URL="**None**" \
|
WEBHOOK_URL="**None**" \
|
||||||
|
WEBHOOK_ERROR_URL="**None**" \
|
||||||
|
WEBHOOK_PRE_BACKUP_URL="**None**" \
|
||||||
|
WEBHOOK_POST_BACKUP_URL="**None**" \
|
||||||
WEBHOOK_EXTRA_ARGS=""
|
WEBHOOK_EXTRA_ARGS=""
|
||||||
|
|
||||||
COPY hooks /hooks
|
COPY hooks /hooks
|
||||||
|
|||||||
+44
-11
@@ -5,9 +5,9 @@ set -e
|
|||||||
# Possible actions: error, pre-backup, post-backup
|
# Possible actions: error, pre-backup, post-backup
|
||||||
ACTION="${1}"
|
ACTION="${1}"
|
||||||
|
|
||||||
if [ "${WEBHOOK_URL}" != "**None**" ]; then
|
case "${ACTION}" in
|
||||||
case "${ACTION}" in
|
"error")
|
||||||
"error")
|
if [ "${WEBHOOK_URL}" != "**None**" ]; then
|
||||||
echo "Execute error webhook call to ${WEBHOOK_URL}"
|
echo "Execute error webhook call to ${WEBHOOK_URL}"
|
||||||
curl --request POST \
|
curl --request POST \
|
||||||
--url "${WEBHOOK_URL}" \
|
--url "${WEBHOOK_URL}" \
|
||||||
@@ -16,11 +16,34 @@ if [ "${WEBHOOK_URL}" != "**None**" ]; then
|
|||||||
--max-time 10 \
|
--max-time 10 \
|
||||||
--retry 5 \
|
--retry 5 \
|
||||||
${WEBHOOK_EXTRA_ARGS}
|
${WEBHOOK_EXTRA_ARGS}
|
||||||
;;
|
fi
|
||||||
# "pre-backup")
|
if [ "${WEBHOOK_ERROR_URL}" != "**None**" ]; then
|
||||||
# echo "Nothing to do"
|
echo "Execute error webhook call to ${WEBHOOK_ERROR_URL}"
|
||||||
# ;;
|
curl --request POST \
|
||||||
"post-backup")
|
--url "${WEBHOOK_ERROR_URL}" \
|
||||||
|
--header 'Content-Type: application/json' \
|
||||||
|
--data '{"status": "error"}' \
|
||||||
|
--max-time 10 \
|
||||||
|
--retry 5 \
|
||||||
|
${WEBHOOK_EXTRA_ARGS}
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
|
"pre-backup")
|
||||||
|
if [ "${WEBHOOK_PRE_BACKUP_URL}" != "**None**" ]; then
|
||||||
|
echo "Execute pre-backup webhook call to ${WEBHOOK_PRE_BACKUP_URL}"
|
||||||
|
curl --request POST \
|
||||||
|
--url "${WEBHOOK_PRE_BACKUP_URL}" \
|
||||||
|
--header 'Content-Type: application/json' \
|
||||||
|
--data '{"status": "pre-backup"}' \
|
||||||
|
--max-time 10 \
|
||||||
|
--retry 5 \
|
||||||
|
${WEBHOOK_EXTRA_ARGS}
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
|
"post-backup")
|
||||||
|
if [ "${WEBHOOK_URL}" != "**None**" ]; then
|
||||||
echo "Execute post-backup webhook call to ${WEBHOOK_URL}"
|
echo "Execute post-backup webhook call to ${WEBHOOK_URL}"
|
||||||
curl --request POST \
|
curl --request POST \
|
||||||
--url "${WEBHOOK_URL}" \
|
--url "${WEBHOOK_URL}" \
|
||||||
@@ -29,6 +52,16 @@ if [ "${WEBHOOK_URL}" != "**None**" ]; then
|
|||||||
--max-time 10 \
|
--max-time 10 \
|
||||||
--retry 5 \
|
--retry 5 \
|
||||||
${WEBHOOK_EXTRA_ARGS}
|
${WEBHOOK_EXTRA_ARGS}
|
||||||
;;
|
fi
|
||||||
esac
|
if [ "${WEBHOOK_POST_BACKUP_URL}" != "**None**" ]; then
|
||||||
fi
|
echo "Execute post-backup webhook call to ${WEBHOOK_POST_BACKUP_URL}"
|
||||||
|
curl --request POST \
|
||||||
|
--url "${WEBHOOK_POST_BACKUP_URL}" \
|
||||||
|
--header 'Content-Type: application/json' \
|
||||||
|
--data '{"status": "post-backup"}' \
|
||||||
|
--max-time 10 \
|
||||||
|
--retry 5 \
|
||||||
|
${WEBHOOK_EXTRA_ARGS}
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|||||||
Reference in New Issue
Block a user