zammad-docker-compose/containers/zammad-postgresql/backup.sh
André Bauer ce696bad8b
added init container (installation / update)... (#2)
- added memcached container (currently develop branch needed)
- put all zammad services in one kubernetes pod to be able to use empty dir volume for tmp
- switched to kubernetes deployments
- switched to ReadWriteOnce kubernetes volume claims
- added init container to elasticsearch & zammad kubernetes deployments
- added IMAGE_REPO var for docker compose to .env file
- run nginx from zammad container (preparation for stateless updates)
- removed docker-compose-build.yml
- use private docker repos in compose & kubernetes
- change compose volume names
2017-11-26 21:25:57 +01:00

46 lines
985 B
Bash

#!/bin/bash
set -e
function check_railsserver_available {
until (echo > /dev/tcp/zammad-railsserver/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
# 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
}
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