zammad-docker-compose/containers/zammad-postgresql/backup.sh
André Bauer 1f5c9036c2 - fixed ipv6 in google kubernetes engine
- replaced wget with curl
- made zammad image smaller by using tar.gz install instead of git clone
- moved sed commands to entrypoint
- added variables to entrypoint to set used servers dynamically
- added kubernetes backup cronjob
- added postgresql volume to compose file
- write nginx logs to stdout & stderr
- create zammad user & group manually with uid/gid 1000
2017-12-03 19:41:55 +01:00

56 lines
1.2 KiB
Bash

#!/bin/bash
set -e
: "${ZAMMAD_RAILSSERVER_HOST:=zammad-railsserver}"
function check_railsserver_available {
until (echo > /dev/tcp/${ZAMMAD_RAILSSERVER_HOST}/3000) &> /dev/null; do
echo "waiting for railsserver to be ready..."
sleep 60
done
}
function zammad_backup {
TIMESTAMP="$(date +'%Y%m%d%H%M%S')"
echo "${TIMESTAMP} - backuping zammad..."
# delete old backups
if [ -d "${BACKUP_DIR}" ] && [ -n "$(ls ${BACKUP_DIR})" ]; then
find ${BACKUP_DIR}/*_zammad_*.gz -type f -mtime +${HOLD_DAYS} -exec rm {} \;
fi
if [ "${NO_FILE_BACKUP}" != "yes" ]; then
# tar files
tar -czf ${BACKUP_DIR}/${TIMESTAMP}_zammad_files.tar.gz ${ZAMMAD_DIR}
fi
#db backup
pg_dump --dbname=postgresql://postgres@zammad-postgresql:5432/zammad_production | gzip > ${BACKUP_DIR}/${TIMESTAMP}_zammad_db.psql.gz
}
if [ "$1" = 'zammad-backup' ]; then
check_railsserver_available
while true; do
zammad_backup
# wait until next backup
sleep ${BACKUP_SLEEP}
done
fi
if [ "$1" = 'zammad-backup-once' ]; then
check_railsserver_available
zammad_backup
fi
if [ "$1" = 'zammad-backup-db' ]; then
NO_FILE_BACKUP="yes"
zammad_backup
fi