From b6b0b058890b38afc21f1c597cc1154a8e2d7db0 Mon Sep 17 00:00:00 2001 From: Kersten Burkhardt Date: Tue, 24 Oct 2017 22:50:44 +0200 Subject: [PATCH] Added backup once --- containers/zammad-postgresql/backup.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/containers/zammad-postgresql/backup.sh b/containers/zammad-postgresql/backup.sh index 62e47d4..3bfc019 100644 --- a/containers/zammad-postgresql/backup.sh +++ b/containers/zammad-postgresql/backup.sh @@ -25,3 +25,24 @@ if [ "$1" = 'zammad-backup' ]; then sleep ${BACKUP_SLEEP} done fi + +if [ "$1" = 'zammad-backup-once' ]; then + # wait for zammad process coming up + until (echo > /dev/tcp/zammad-railsserver/3000) &> /dev/null; do + echo "backup waiting for zammads railsserver to be ready..." + sleep 2 + done + + TIMESTAMP="$(date +'%Y%m%d%H%M%S')" + + echo "${TIMESTAMP} - backuping zammad..." + + # delete old backups + test -d ${BACKUP_DIR} && find ${BACKUP_DIR}/*_zammad_*.gz -type f -mtime +${HOLD_DAYS} -exec rm {} \; + + # tar files + tar -czf ${BACKUP_DIR}/${TIMESTAMP}_zammad_files.tar.gz ${ZAMMAD_DIR} + + #db backup + pg_dump --dbname=postgresql://postgres@zammad-postgresql:5432/zammad_production | gzip > ${BACKUP_DIR}/${TIMESTAMP}_zammad_db.psql.gz +fi