timed backup script with backup time (#339)
* Update backup.sh - new zammad-timed-backup which uses fixed backup time $BACKUP_TIME * Update docker-compose.yml - $BACKUP_TIME added - timed backup as command * merge request and linting fixes * arithmetic linting fix * not related to merge request but fixes linting in check_railsserver_available
This commit is contained in:
parent
ef8830e636
commit
281b5f317f
@ -10,10 +10,11 @@ services:
|
||||
- zammad-postgresql
|
||||
entrypoint: /usr/local/bin/backup.sh
|
||||
environment:
|
||||
- BACKUP_SLEEP=86400
|
||||
- BACKUP_TIME=03:00
|
||||
- HOLD_DAYS=10
|
||||
- POSTGRESQL_USER=${POSTGRES_USER}
|
||||
- POSTGRESQL_PASSWORD=${POSTGRES_PASS}
|
||||
- TZ=Europe/Berlin
|
||||
image: postgres:${POSTGRES_VERSION}
|
||||
restart: ${RESTART}
|
||||
volumes:
|
||||
|
@ -11,7 +11,7 @@ set -e
|
||||
: "${POSTGRESQL_DB:=zammad_production}"
|
||||
|
||||
function check_railsserver_available {
|
||||
until (echo > /dev/tcp/${ZAMMAD_RAILSSERVER_HOST}/${ZAMMAD_RAILSSERVER_PORT}) &> /dev/null; do
|
||||
until (echo > "/dev/tcp/$ZAMMAD_RAILSSERVER_HOST/$ZAMMAD_RAILSSERVER_PORT") &> /dev/null; do
|
||||
echo "waiting for railsserver to be ready..."
|
||||
sleep 60
|
||||
done
|
||||
@ -43,10 +43,15 @@ if [ "$1" = 'zammad-backup' ]; then
|
||||
check_railsserver_available
|
||||
|
||||
while true; do
|
||||
NOW_TIMESTAMP=$(date +%s)
|
||||
TOMORROW_DATE=$(date -d@"$((NOW_TIMESTAMP + 24*60*60))" +%Y-%m-%d)
|
||||
|
||||
zammad_backup
|
||||
|
||||
# wait until next backup
|
||||
sleep "${BACKUP_SLEEP}"
|
||||
NEXT_TIMESTAMP=$(date -d "$TOMORROW_DATE $BACKUP_TIME" +%s)
|
||||
NOW_TIMESTAMP=$(date +%s)
|
||||
|
||||
sleep $((NEXT_TIMESTAMP - NOW_TIMESTAMP))
|
||||
done
|
||||
fi
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user