]> git.decadent.org.uk Git - dak.git/blob - scripts/debian/sync-dd
Do not require overridecodename to be set.
[dak.git] / scripts / debian / sync-dd
1 #! /bin/bash
2
3 # Copyright (C) 2011,2013, Joerg Jaspert <joerg@debian.org>
4 # Copyright (C) 2012, Ansgar Burchardt <ansgar@debian.org>
5 #
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License as
8 # published by the Free Software Foundation; version 2.
9 #
10 # This program is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 # General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
19 set -e
20 set -u
21 set -E
22
23 export LANG=C
24 export LC_ALL=C
25
26 export SCRIPTVARS=/srv/ftp-master.debian.org/dak/config/debian/vars
27 . $SCRIPTVARS
28
29 usage() {
30     echo "usage: $0 <lock> <host1> <host2> sync|code"
31     echo
32     echo "sync dd-accessible copy of the archive"
33     echo
34     echo "arguments:"
35     echo "  lock:      file used for locking"
36     echo "  host1:     hostname for syncing /srv/ftp-master.debian.org"
37     echo "  host2:     hostname for syncing /srv/ftp.debian.org"
38     echo "  sync|code: sync syncs everything"
39     echo "             code only syncs the dak/ directory (uses host1 value as target)"
40     exit ${1:-0}
41 }
42
43 if [ $# -ne 4 ]; then
44   usage 1
45 fi
46
47 lockfile="${lockdir}/${1}"
48 host1="${2}"
49 host2="${3}"
50 mode="${4}"
51
52 # extra options for rsync of /srv/ftp-master.debian.org
53 extra1=""
54
55 cleanup() {
56     rm -f "${lockfile}"
57 }
58 trap cleanup EXIT TERM HUP INT QUIT
59
60 # Also, NEVER use --delete-excluded!
61 if lockfile -r3 "${lockfile}"; then
62     case "${mode}" in
63         sync)
64             rsync -aH -B8192 \
65                   ${extra1} \
66                   --exclude "/.nobackup" \
67                   --exclude "/backup/*.xz" \
68                   --exclude "/backup/dump*" \
69                   --exclude "/build-queues/" \
70                   --exclude "/database/*.db" \
71                   --exclude ".da-backup.trace" \
72                   --exclude "/export/changelogs/tmp*/" \
73                   --exclude "/ftp" \
74                   --exclude "lost+found" \
75                   --exclude "/lock/" \
76                   --exclude "/mirror" \
77                   --exclude "/morgue/" \
78                   --exclude "/queue/bts_version_track/" \
79                   --exclude "/queue/unchecked/" \
80                   --exclude "/s3kr1t" \
81                   --exclude "/scripts/s3kr1t" \
82                   --exclude "/tmp/" \
83                   --exclude "/public/incoming.debian.org" \
84                   --delete --delete-after \
85                   --timeout 3600 \
86                   -e 'ssh -o ConnectTimeout=30 -o SetupTimeout=30' \
87                   /srv/ftp-master.debian.org/ "${host1}:/srv/ftp-master.debian.org/"
88             # command for the remote side:
89             # command="rsync --server -lHogDtpre.iLsf -B8192 --timeout=3600 --delete-after . /srv/ftp-master.debian.org/"
90
91             rsync -aH -B8192 \
92                   --exclude "/.nobackup" \
93                   --exclude mirror \
94                   --exclude rsync/ \
95                   --exclude lost+found \
96                   --exclude .da-backup.trace \
97                   --exclude web-users/ \
98                   --delete --delete-after \
99                   --timeout 3600 \
100                   -e 'ssh -o ConnectTimeout=30 -o SetupTimeout=30' \
101                   /srv/ftp.debian.org/ "${host2}:/srv/ftp.debian.org/"
102             # command for the remote side:
103             # command="rsync --server -lHogDtpre.iLsf -B8192 --timeout=3600 --delete-after . /srv/ftp.debian.org/"
104             ;;
105         code)
106             rsync -aH -B8192 \
107                   --exclude "/.nobackup" \
108                   --delete --delete-after \
109                   --timeout 3600 \
110                   -e 'ssh -o ConnectTimeout=30 -o SetupTimeout=30' \
111                   /srv/ftp-master.debian.org/dak/ "${host1}:/srv/ftp-master.debian.org/dak/"
112             # command for the remote side:
113             # command="rsync --server -lHogDtpre.iLsf -B8192 --timeout=3600 --delete-after . /srv/ftp-master.debian.org/dak/"
114             ;;
115         *)
116             echo "Unknown mode ${mode}." >&2
117             exit 1
118             ;;
119     esac
120 else
121     echo "Couldn't get the lock, not syncing"
122     exit 0
123 fi