This commit is contained in:
+12
-4
@@ -1,14 +1,22 @@
|
||||
#!/bin/sh
|
||||
|
||||
set +e
|
||||
set -e
|
||||
|
||||
# crond runs jobs with a bare environment (HOME/PATH/SHELL only), so the
|
||||
# container env is dumped here and sourced back by backup.sh on every run.
|
||||
ENV_FILE=/tmp/container.env
|
||||
export -p | grep -v -E "^export (PWD|SHLVL|OLDPWD|_)=" > "$ENV_FILE"
|
||||
chmod 600 "$ENV_FILE"
|
||||
|
||||
# Create crontab in a writable location and set proper permissions
|
||||
mkdir -p /tmp/crontabs
|
||||
echo "${CRONTAB:-"0 * * * *"} /scripts/backup.sh >> /proc/1/fd/1 2>&1" > /tmp/crontabs/root
|
||||
echo "${CRONTAB:-"0 * * * *"} /scripts/backup.sh --from-cron >> /proc/1/fd/1 2>&1" > /tmp/crontabs/root
|
||||
chmod 644 /tmp/crontabs/root
|
||||
|
||||
# Run initial backup
|
||||
/scripts/backup.sh
|
||||
echo "[entrypoint] schedule: ${CRONTAB:-"0 * * * *"} (TZ=${TZ:-UTC})"
|
||||
|
||||
# Run initial backup (do not abort the container if it fails)
|
||||
/scripts/backup.sh || echo "[entrypoint] initial backup failed, continuing to crond"
|
||||
|
||||
# Start crond in foreground with debug output
|
||||
exec crond -f -c /tmp/crontabs -d 0
|
||||
|
||||
Reference in New Issue
Block a user