Check in new hcoop-all-db-backup script
[clinton/scripts.git] / hcoop-backup
1 #!/bin/bash -e
2
3 #
4 # run this script as root, on deleuze, in a directory that WILL NOT be
5 # part of the backup (/tmp is a good choice).
6 #
7
8 # FIXME:
9 # postgres dumps
10 # mysql dumps
11
12 #KEYFILE=$1
13 KEYFILE=/etc/backup-encryption-key
14
15 echo building package lists...
16 dpkg -W -f='${Package}\n' > packages
17 find / /usr/ /usr/local/ /var/ -xdev | sort | uniq > allfiles
18 dpkg-query -W -f='${Package}\n' | xargs dpkg -L | sort | uniq > debfiles
19 dpkg-query -W -f='${Conffiles}\n' | grep / | sort | uniq > conffiles
20
21 diff allfiles debfiles | grep '^<' | cut -b 3- | \
22 grep -v ^/var/cache | \
23 grep -v ^/var/tmp | \
24 grep -v ^/var/lib/dpkg | \
25 grep -v ^/var/backups | \
26 grep -v ^/var/lib/changetrack | \
27 grep -v ^/var/run | \
28 grep -v ^/var/lock | \
29 grep -v ^/var/lib/ucf | \
30 grep -v ^/vicepa | \
31 grep -v ^/home | \
32 grep -v ^/tmp | \
33 grep -v '^/afs$' | \
34 grep -v '^/$' | \
35 grep -v '^/usr/$' | \
36 grep -v ^/usr/src | \
37 cat > backupfiles
38
39 cat backupfiles | \
40 grep -v ^/home | \
41 grep -v ^/usr/local | \
42 grep -v ^/var/spool | \
43 grep -v ^/var/log | \
44 grep -v ^/usr/lib/python2.4/ | \
45 grep -v ^/var/lib/python-support | \
46 grep -v ^/usr/share/man | \
47 grep -v ^/media | \
48 grep -v ^/vmlinuz | \
49 grep -v ^/vmlinuz.old | \
50 grep -v '^/sbin/[a-z\-]*.modutils$' | \
51 cat > annoyingfiles-
52
53 for A in `cat annoyingfiles-`
54 do \
55 test -L "$A" || echo "$A"
56 done > annoyingfiles
57
58 cat annoyingfiles | \
59 grep -v ^/opt/dell/srvadmin/ | \
60 grep -v ^/boot/ | \
61 grep -v ^/etc/ | \
62 grep -v ^/root/ | \
63 grep -v ^/var/ | \
64 grep -v ^/lib/modules/ | \
65 grep -v ^/var/domtool/ | \
66 grep -v ^/var/lib/mysql/ | \
67 grep -v ^/var/lib/postgres/ | \
68 grep -v ^/var/lib/postgresql/ | \
69 cat > complain
70
71 mail -a 'From: Adam Megacz <megacz@hcoop.net>' \
72 -s "annoying files found on deleuze (please do something about them)" admins@hcoop.net \
73 < complain
74
75 tar cvlpjf - -C / -T backupfiles | bzip2 | ccrypt -k $KEYFILE -e > hcoop.backup.tar.bz2.aescrypt
76 du -chs hcoop.backup.tar.bz2.aescrypt
77
78 vos listvol deleuze | tail -n +2 | head -n -3 | cut -b1-34 | grep -v "\.backup .*$" | grep -v "\.readonly .*$" > volumes
79 for A in `cat volumes`
80 do \
81 echo "dumping afs volume $A..."
82 time vos dump -id $A -localauth -clone | bzip2 | ccrypt -k $KEYFILE -e > $A.dump.bz2.aescrypt
83 done