]> git.decadent.org.uk Git - dak.git/blob - config/homedir/syncdd.sh
Do not sync lock/stages/ to ries.
[dak.git] / config / homedir / syncdd.sh
1 #!/bin/bash
2
3 # Copyright (C) 2011 Joerg Jaspert <joerg@debian.org>
4 #
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License as
7 # published by the Free Software Foundation; version 2.
8 #
9 # This program is distributed in the hope that it will be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 # General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
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 EXTRA=""
30
31 check_commandline() {
32     while [ $# -gt 0 ]; do
33         case "$1" in
34             sync)
35                 EXTRA="--exclude ftp/"
36                 ;;
37             pool)
38                 ;;
39             *)
40                 echo "Unknown option ${1} ignored"
41                 ;;
42         esac
43         shift  # Check next set of parameters.
44     done
45 }
46
47 if [ $# -gt 0 ]; then
48     ORIGINAL_COMMAND=$*
49 else
50     ORIGINAL_COMMAND=""
51 fi
52
53 SSH_ORIGINAL_COMMAND=${SSH_ORIGINAL_COMMAND:-""}
54 if [ -n "${SSH_ORIGINAL_COMMAND}" ]; then
55     set "nothing" "${SSH_ORIGINAL_COMMAND}"
56     shift
57     check_commandline $*
58 fi
59
60 if [ -n "${ORIGINAL_COMMAND}" ]; then
61     set ${ORIGINAL_COMMAND}
62     check_commandline $*
63 fi
64
65
66 cleanup() {
67     rm -f "${HOME}/sync.lock"
68 }
69 trap cleanup EXIT TERM HUP INT QUIT
70
71 # not using $lockdir as thats inside the rsync dir, and --delete would
72 # kick the lock away. Yes we could exclude it, but wth bother?
73 #
74 # Also, NEVER use --delete-excluded!
75 if lockfile -r3 ${HOME}/sync.lock; then
76     cd $base/
77     rsync -aH -B8192 \
78             --exclude backup/*.xz \
79             --exclude backup/dump* \
80         ${EXTRA} \
81             --exclude mirror \
82             --exclude morgue/ \
83             --exclude=lost+found/ \
84             --exclude .da-backup.trace \
85             --exclude lock/stages/ \
86             --delete \
87             --delete-after \
88             --timeout 3600 \
89             -e 'ssh -o ConnectTimeout=30 -o SetupTimeout=30' \
90             ftpmaster-sync:/srv/ftp-master.debian.org/ .
91
92     cd $public/
93     rsync -aH -B8192 \
94             --exclude mirror \
95             --exclude rsync/ \
96             --exclude=lost+found/ \
97             --exclude .da-backup.trace \
98             --exclude web-users/ \
99             --delete \
100             --delete-after \
101             --timeout 3600 \
102             -e 'ssh -o ConnectTimeout=30 -o SetupTimeout=30' \
103             ftpmaster-sync2:/srv/ftp.debian.org/ .
104
105 else
106     echo "Couldn't get the lock, not syncing"
107     exit 0
108 fi
109
110
111 ## ftpmaster-sync is defined in .ssh/config as:
112 # Host ftpmaster-sync
113 #   Hostname franck.debian.org
114 #   User dak
115 #   IdentityFile ~dak/.ssh/syncftpmaster
116 #   ForwardX11 no
117 #   ForwardAgent no
118 #   StrictHostKeyChecking yes
119 #   PasswordAuthentication no
120 #   BatchMode yes
121
122 ## ftpmaster-sync2 is the same, just a second ssh key