]> git.decadent.org.uk Git - dak.git/blob - config/homedir/syncdd.sh
add the syncscript for ries. also call it hourly
[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 cleanup() {
30     rm -f "${HOME}/sync.lock"
31 }
32 trap cleanup EXIT TERM HUP INT QUIT
33
34 # not using $lockdir as thats inside the rsync dir, and --delete would
35 # kick the lock away. Yes we could exclude it, but wth bother?
36 #
37 # Also, NEVER use --delete-excluded!
38 if lockfile -r3 ${HOME}/sync.lock; then
39     cd $base/
40     rsync -aH -B8192 \
41             --exclude backup/*.xz \
42             --exclude backup/dump* \
43             --exclude ftp/ \
44             --exclude mirror/ \
45             --exclude morgue/ \
46             --exclude=lost+found/ \
47             --exclude .da-backup.trace \
48             --delete \
49             --delete-after \
50             --timeout 3600 \
51             -e 'ssh -o ConnectTimeout=30 -o SetupTimeout=30' \
52             ftpmaster-sync:/srv/ftp-master.debian.org/ .
53
54     cd $public/
55     rsync -avH -B8192 \
56             --exclude mirror \
57             --exclude rsync/ \
58             --exclude=lost+found/ \
59             --exclude .da-backup.trace \
60             --exclude web-users/ \
61             --delete \
62             --delete-after \
63             --timeout 3600 \
64             -e 'ssh -o ConnectTimeout=30 -o SetupTimeout=30' \
65             ftpmaster-sync2:/srv/ftp.debian.org/ .
66
67 else
68     echo "Couldn't get the lock, not syncing"
69     exit 0
70 fi
71
72
73 ## ftpmaster-sync is defined in .ssh/config as:
74 # Host ftpmaster-sync
75 #   Hostname franck.debian.org
76 #   User dak
77 #   IdentityFile ~dak/.ssh/syncftpmaster
78 #   ForwardX11 no
79 #   ForwardAgent no
80 #   StrictHostKeyChecking yes
81 #   PasswordAuthentication no
82 #   BatchMode yes
83
84 ## ftpmaster-sync2 is the same, just a second ssh key