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
|
- zammad-postgresql
|
||||||
entrypoint: /usr/local/bin/backup.sh
|
entrypoint: /usr/local/bin/backup.sh
|
||||||
environment:
|
environment:
|
||||||
- BACKUP_SLEEP=86400
|
- BACKUP_TIME=03:00
|
||||||
- HOLD_DAYS=10
|
- HOLD_DAYS=10
|
||||||
- POSTGRESQL_USER=${POSTGRES_USER}
|
- POSTGRESQL_USER=${POSTGRES_USER}
|
||||||
- POSTGRESQL_PASSWORD=${POSTGRES_PASS}
|
- POSTGRESQL_PASSWORD=${POSTGRES_PASS}
|
||||||
|
- TZ=Europe/Berlin
|
||||||
image: postgres:${POSTGRES_VERSION}
|
image: postgres:${POSTGRES_VERSION}
|
||||||
restart: ${RESTART}
|
restart: ${RESTART}
|
||||||
volumes:
|
volumes:
|
||||||
|
@ -11,7 +11,7 @@ set -e
|
|||||||
: "${POSTGRESQL_DB:=zammad_production}"
|
: "${POSTGRESQL_DB:=zammad_production}"
|
||||||
|
|
||||||
function check_railsserver_available {
|
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..."
|
echo "waiting for railsserver to be ready..."
|
||||||
sleep 60
|
sleep 60
|
||||||
done
|
done
|
||||||
@ -43,10 +43,15 @@ if [ "$1" = 'zammad-backup' ]; then
|
|||||||
check_railsserver_available
|
check_railsserver_available
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
|
NOW_TIMESTAMP=$(date +%s)
|
||||||
|
TOMORROW_DATE=$(date -d@"$((NOW_TIMESTAMP + 24*60*60))" +%Y-%m-%d)
|
||||||
|
|
||||||
zammad_backup
|
zammad_backup
|
||||||
|
|
||||||
# wait until next backup
|
NEXT_TIMESTAMP=$(date -d "$TOMORROW_DATE $BACKUP_TIME" +%s)
|
||||||
sleep "${BACKUP_SLEEP}"
|
NOW_TIMESTAMP=$(date +%s)
|
||||||
|
|
||||||
|
sleep $((NEXT_TIMESTAMP - NOW_TIMESTAMP))
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user