#!/bin/sh # /etc/cron.daily/gitsync - publish repos once a day, as the normal user. # Runs as root via cron.daily, drops to USER (config, ssh key and repos live in that home). # If the server is not reachable it retries a few times, then gives up until tomorrow. USER=n76310 HOST=162.19.227.194 RETRIES=6 # attempts WAIT=600 # seconds between attempts (10 min) # root-only files of backup.conf projects ([root:*], [system:*]) -> /var/cache/gitsync/USER.tar /usr/bin/gitsync --collect-root "$USER" -q || echo "gitsync: collecting root-only files failed" >&2 i=0 while [ "$i" -lt "$RETRIES" ]; do if ping -c1 -W5 "$HOST" >/dev/null 2>&1 && su - "$USER" -c '/usr/bin/gitsync -q'; then exit 0 fi i=$((i + 1)) [ "$i" -lt "$RETRIES" ] && sleep "$WAIT" done echo "gitsync: server $HOST not reachable after $RETRIES attempts, giving up until tomorrow" >&2 exit 0