mirror of
https://github.com/prodrigestivill/docker-postgres-backup-local.git
synced 2026-05-31 08:37:58 +00:00
76 lines
2.0 KiB
Bash
Executable File
76 lines
2.0 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
set -e
|
|
|
|
# Possible actions: error, pre-backup, post-backup
|
|
ACTION="${1}"
|
|
|
|
if [ "${WEBHOOK_URL}" != "**None**" ]; then
|
|
case "${ACTION}" in
|
|
"error")
|
|
echo "Execute error webhook call to ${WEBHOOK_URL}"
|
|
curl --request POST \
|
|
--url "${WEBHOOK_URL}" \
|
|
--header 'Content-Type: application/json' \
|
|
--data '{"status": "error"}' \
|
|
--max-time 10 \
|
|
--retry 5 \
|
|
${WEBHOOK_EXTRA_ARGS}
|
|
;;
|
|
# "pre-backup")
|
|
# echo "Nothing to do"
|
|
# ;;
|
|
"post-backup")
|
|
echo "Execute post-backup webhook call to ${WEBHOOK_URL}"
|
|
curl --request POST \
|
|
--url "${WEBHOOK_URL}" \
|
|
--header 'Content-Type: application/json' \
|
|
--data '{"status": "post-backup"}' \
|
|
--max-time 10 \
|
|
--retry 5 \
|
|
${WEBHOOK_EXTRA_ARGS}
|
|
;;
|
|
esac
|
|
fi
|
|
|
|
case "${ACTION}" in
|
|
"error")
|
|
if [ "${WEBHOOK_ERROR_URL}" != "**None**" ]; then
|
|
echo "Execute error webhook call to ${WEBHOOK_ERROR_URL}"
|
|
curl --request POST \
|
|
--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_POST_BACKUP_URL}" != "**None**" ]; then
|
|
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
|