Browse Source

Added alerting to telegram

pull/118/head
Igor Diakonov 5 years ago
parent
commit
34326102a9
  1. 4
      postgres-backup-s3/Dockerfile
  2. 4
      postgres-backup-s3/backup.sh

4
postgres-backup-s3/Dockerfile

@ -18,6 +18,10 @@ ENV S3_PATH 'backup'
ENV S3_ENDPOINT **None**
ENV S3_S3V4 no
ENV SCHEDULE **None**
# Telegram alerting
ENV BOT_ID **None**
ENV CHAT_ID **None**
ENV MSG ''
ADD run.sh run.sh
ADD backup.sh backup.sh

4
postgres-backup-s3/backup.sh

@ -63,6 +63,10 @@ pg_dump $POSTGRES_HOST_OPTS -Fc $POSTGRES_DATABASE | gzip > dump.sql.gz
echo "Uploading dump to $S3_BUCKET"
if [ "${BOT_ID}" == "**None**" ] || [ "$CHAT_ID" == "**None**" ] || [ -z "$MSG" ] ; then
cat dump.sql.gz | aws $AWS_ARGS s3 cp - s3://$S3_BUCKET/$S3_PREFIX/${POSTGRES_DATABASE}_$(date +"%Y-%m-%dT%H:%M:%SZ").sql.gz || exit 2
else
cat dump.sql.gz | aws $AWS_ARGS s3 cp - s3://$S3_BUCKET/$S3_PREFIX/${POSTGRES_DATABASE}_$(date +"%Y-%m-%dT%H:%M:%SZ").sql.gz || (curl "https://api.telegram.org/$BOT_ID/sendMessage?chat_id=$CHAT_ID&parse_mode=html&text=$MSG" && exit 2) || exit 2
fi
echo "SQL backup uploaded successfully"
Loading…
Cancel
Save