From 3af7425b3d315e5b340337f5ec806ff98cd19633 Mon Sep 17 00:00:00 2001 From: Miku Laitinen Date: Fri, 13 Sep 2019 17:07:03 +0300 Subject: [PATCH] [FEAT] Allow calling a healthcheck URL after a successful backup --- README.md | 1 + bin/backup.sh | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/README.md b/README.md index 5cea58f..7facd70 100644 --- a/README.md +++ b/README.md @@ -119,6 +119,7 @@ Environment variables | MONGODB_AUTHDB | Authentication DB name | - | | CRONMODE | If set "true", this container is executed in cron mode. In cron mode, the script will be executed with the specified arguments and at the time specified by CRON_EXPRESSION. | "false" | | CRON_EXPRESSION | Cron expression (ex. "CRON_EXPRESSION=0 4 * * *" if you want to run at 4:00 every day) | - | +| HEALTHCHECKS_URL | URL that gets called after a successful backup (eg. https://healthchecks.io) | - | ### For `restore` diff --git a/bin/backup.sh b/bin/backup.sh index 1d0ebe7..21b0aca 100755 --- a/bin/backup.sh +++ b/bin/backup.sh @@ -69,6 +69,11 @@ elif [ `echo $TARGET_BUCKET_URL | cut -f1 -d":"` == "gs" ]; then gs_copy_file ${TARBALL_FULLPATH} ${TARGET_BUCKET_URL} fi +# call healthchecks url for successful backup +if [ "x${HEALTHCHECKS_URL}" != "x" ]; then + curl -fsS --retry 3 ${HEALTHCHECKS_URL} > /dev/null +fi + # clean up working files if in cron mode if ${CRONMODE} ; then rm -rf ${TARGET}