1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-11-04 22:40:12 +01:00
fdroidserver/examples/mirror-to-mirror.sh
Hans-Christoph Steiner ce77a33228
mirror-to-mirror.sh: set 1h timeout for rsync runs
This script is run every 10 minutes or so to push new files to the primary
mirrors.  It sets a lock to prevent multiple copies from running in
parallel.  Yesterday, one rsync process got stuck and never exited, thereby
preventing this script from running.  Adding a 1h timeout seems like a safe
way to deal with this kind of problem.  This would not deal with rsync
getting so stuck that it fails to heed the timeout, hopefully that's not an
issue.
2023-07-25 14:52:29 +02:00

30 lines
1.1 KiB
Bash

#!/bin/bash
#
# This script syncs the entire repo to the primary mirrors. It is
# meant to run in a cronjob quite frequently, as often as there are
# files to send.
#
# This script expects the receiving side to have the following
# preceeding the ssh key entry in ~/.ssh/authorized_keys:
# command="rsync --server -logDtpre.iLsfx --log-format=X --delete --delay-updates . /path/to/htdocs/fdroid/",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty
#
set -e
(
flock -n 200
set -e
cd /home/fdroid
for section in repo archive; do
echo "Started $section at `date`:"
for host in fdroid@ftp-push.lysator.liu.se fdroid@plug-mirror.rcac.purdue.edu fdroid@ftp.agdsn.de; do
set -x
# be super careful with the trailing slashes here! if one is wrong, it'll delete the entire section!
rsync --archive --delay-updates --progress --delete \
--timeout=3600 \
/home/fdroid/public_html/${section} \
${host}:/srv/fdroid-mirror.at.or.at/htdocs/fdroid/ &
set +x
done
wait
done
) 200>/var/lock/root_fdroidmirrortomirror