123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- #! /bin/bash
- # Copyright (C) 2011,2013, Joerg Jaspert <joerg@debian.org>
- # Copyright (C) 2012, Ansgar Burchardt <ansgar@debian.org>
- #
- # This program is free software; you can redistribute it and/or
- # modify it under the terms of the GNU General Public License as
- # published by the Free Software Foundation; version 2.
- #
- # This program is distributed in the hope that it will be useful, but
- # WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- # General Public License for more details.
- #
- # You should have received a copy of the GNU General Public License
- # along with this program; if not, write to the Free Software
- # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- set -e
- set -u
- set -E
- export LANG=C
- export LC_ALL=C
- export SCRIPTVARS=/srv/ftp-master.debian.org/dak/config/debian/vars
- . $SCRIPTVARS
- usage() {
- echo "usage: $0 <lock> <host1> <host2> sync|code"
- echo
- echo "sync dd-accessible copy of the archive"
- echo
- echo "arguments:"
- echo " lock: file used for locking"
- echo " host1: hostname for syncing /srv/ftp-master.debian.org"
- echo " host2: hostname for syncing /srv/ftp.debian.org"
- echo " sync|code: sync syncs everything"
- echo " code only syncs the dak/ directory (uses host1 value as target)"
- exit ${1:-0}
- }
- if [ $# -ne 4 ]; then
- usage 1
- fi
- lockfile="${lockdir}/${1}"
- host1="${2}"
- host2="${3}"
- mode="${4}"
- # extra options for rsync of /srv/ftp-master.debian.org
- extra1=""
- cleanup() {
- rm -f "${lockfile}"
- }
- trap cleanup EXIT TERM HUP INT QUIT
- # Also, NEVER use --delete-excluded!
- if lockfile -r3 "${lockfile}" 2> /dev/null; then
- case "${mode}" in
- sync)
- rsync -aH -B8192 \
- ${extra1} \
- --exclude "/.nobackup" \
- --exclude "/archive/" \
- --exclude "/backup/*.xz" \
- --exclude "/backup/dump*" \
- --exclude "/build-queues/" \
- --exclude "/database/*.db" \
- --exclude ".da-backup.trace" \
- --exclude "/export/changelogs/tmp*/" \
- --exclude "/ftp" \
- --exclude "lost+found" \
- --exclude "/lock/" \
- --exclude "/mirror" \
- --exclude "/morgue/" \
- --exclude "/queue/bts_version_track/" \
- --exclude "/queue/unchecked/" \
- --exclude "/s3kr1t" \
- --exclude "/scripts/s3kr1t" \
- --exclude "/tmp/" \
- --exclude "/public/incoming.debian.org" \
- --exclude "/tiffani/" \
- --delete --delete-after \
- --timeout 3600 \
- -e 'ssh -o ConnectTimeout=30 -o SetupTimeout=30' \
- /srv/ftp-master.debian.org/ "${host1}:/srv/ftp-master.debian.org/"
- # command for the remote side:
- # command="rsync --server -lHogDtpre.iLsf -B8192 --timeout=3600 --delete-after . /srv/ftp-master.debian.org/"
- rsync -aH -B8192 \
- --exclude "/.nobackup" \
- --exclude mirror \
- --exclude rsync/ \
- --exclude lost+found \
- --exclude .da-backup.trace \
- --exclude web-users/ \
- --delete --delete-after \
- --timeout 3600 \
- -e 'ssh -o ConnectTimeout=30 -o SetupTimeout=30' \
- /srv/ftp.debian.org/ "${host2}:/srv/ftp.debian.org/"
- # command for the remote side:
- # command="rsync --server -lHogDtpre.iLsf -B8192 --timeout=3600 --delete-after . /srv/ftp.debian.org/"
- ;;
- code)
- rsync -aH -B8192 \
- --exclude "/.nobackup" \
- --delete --delete-after \
- --timeout 3600 \
- -e 'ssh -o ConnectTimeout=30 -o SetupTimeout=30' \
- /srv/ftp-master.debian.org/dak/ "${host1}:/srv/ftp-master.debian.org/dak/"
- # command for the remote side:
- # command="rsync --server -lHogDtpre.iLsf -B8192 --timeout=3600 --delete-after . /srv/ftp-master.debian.org/dak/"
- ;;
- *)
- echo "Unknown mode ${mode}." >&2
- exit 1
- ;;
- esac
- else
- #echo "Couldn't get the lock, not syncing"
- exit 0
- fi
|