3 # -*- sh -*- vim: ft=sh sw=4 sts=4
5 PATH="$HOME/bin:/usr/local/bin:/usr/bin:/bin"
6 ARCHIVE="tpope-`date +%Y-%m-%d`.tar.gpg"
8 if [ -f "$HOME/.critical-backuprc" ]; then
9 . "$HOME/.critical-backuprc"
11 echo "Error: Please create a ~/.critical-backuprc which includes EMAIL=,">&2
12 echo "FROM=, and GPGID= lines.">&2
16 exec >/dev/null </dev/null
18 mkdir /tmp/.critical-$LOGNAME-$$
19 chmod 0700 /tmp/.critical-$LOGNAME-$$
21 sync-tpope -g -a /tmp/.critical-$LOGNAME-$$/tpope.tar
22 cd /tmp/.critical-$LOGNAME-$$
23 ln -s "$HOME/.cvs" cvs
24 mysqldump --all-databases > mysqldump.sql
26 tar chf - tpope.tar cvs mysqldump.sql |\
27 gpg -qez 9 -r "$GPGID" --batch --no-tty > $ARCHIVE
29 [ -d "$HOME/backup-`date +%Y`" ] || mkdir "$HOME/backup-`date +%Y`"
30 cp $ARCHIVE "$HOME/backup-`date +%Y`/"
31 scp -Bq -oSetupTimeout=30 $ARCHIVE patman:backup/ 2>/dev/null || \
32 scp -Bq -oSetupTimeout=30 $ARCHIVE chief:backup/ 2>/dev/null
33 scp -Bq -oSetupTimeout=30 $ARCHIVE right:backup/ 2>/dev/null
34 scp -Bq $ARCHIVE snowball:tpope.tar.gpg 2>/dev/null
37 if [ "$d" = 01 -o "$d" = 08 -o "$d" = 16 -o "$d" = 23 -o "$1" = "-m" ]; then
38 mimencode $ARCHIVE | mail -s "Backup for `date +%Y-%m-%d`" $EMAIL \
39 -a "Content-Type: application/octet-stream; name=$ARCHIVE" \
40 -a "Content-Disposition: attachment; filename=$ARCHIVE" \
41 -a "Content-Transfer-Encoding: base64" \
45 if [ "`date +%m%d`" = "0101" -o "$1" = "-c" ]; then
46 mkisofs -r -J -o back.iso "$HOME/backup-`date +%Y`" 2>/dev/null
47 if ! sudo cdrecord -tao -data -multi speed=4 back.iso 2>/dev/null; then
48 echo "Error: blank CD not found. Please call `basename $0` manually" >&2
50 elif [ "`date +%m%d`" = "1231" ]; then
51 s="`sudo cdrecord -msinfo 2>/dev/null`"
53 mkisofs -r -J -o back.iso -M /dev/cdr -C "$s" "$HOME/backup-`date +%Y`" 2>/dev/null
54 sudo cdrecord -tao -data speed=4 back.iso 2>/dev/null
56 echo "Error. Is the CD in the drive?" >&2
58 echo "Yearly backup finished. Please put a blank CD in the drive." >&2
59 elif [ "$d" = 01 -o "$d" = 08 -o "$d" = 16 -o "$d" = 23 ]; then
60 s="`sudo cdrecord -msinfo 2>/dev/null`"
62 mkisofs -r -J -o back.iso -M /dev/cdr -C "$s" "$HOME/backup-`date +%Y`" 2>/dev/null
63 sudo cdrecord -tao -data -multi speed=4 back.iso >/dev/null 2>&1 || \
64 echo "CD burning failed." >&2
66 echo "Error. Is the CD in the drive?" >&2
71 rm -rf /tmp/.critical-$LOGNAME-$$