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 ln -s /var/lib/svn svn
25 mysqldump --all-databases > mysqldump.sql
27 tar chf - tpope.tar cvs |\
28 gpg -qez 9 -r "$GPGID" --batch --no-tty > $ARCHIVE
30 [ -d "$HOME/backup-`date +%Y`" ] || mkdir "$HOME/backup-`date +%Y`"
31 cp $ARCHIVE "$HOME/backup-`date +%Y`/"
32 scp -Bq -oSetupTimeout=30 $ARCHIVE tpope-486.jmwaller.com:backup/ 2>/dev/null
33 scp -Bq $ARCHIVE steve:tpope.tar.gpg 2>/dev/null
36 if [ "$d" = 01 -o "$d" = 08 -o "$d" = 16 -o "$d" = 23 -o "$1" = "-m" ]; then
37 mimencode $ARCHIVE | mail -s "Backup for `date +%Y-%m-%d`" $EMAIL \
38 -a "Content-Type: application/octet-stream; name=$ARCHIVE" \
39 -a "Content-Disposition: attachment; filename=$ARCHIVE" \
40 -a "Content-Transfer-Encoding: base64" \
46 elif [ "`date +%m%d`" = "0101" -o "$1" = "-c" ]; then
47 mkisofs -r -J -o back.iso "$HOME/backup-`date +%Y`" 2>/dev/null
48 if ! sudo cdrecord -tao -data -multi speed=4 back.iso 2>/dev/null; then
49 echo "Error: blank CD not found. Please call `basename $0` manually" >&2
51 elif [ "`date +%m%d`" = "1231" ]; then
52 s="`sudo cdrecord -msinfo 2>/dev/null`"
54 mkisofs -r -J -o back.iso -M /dev/cdr -C "$s" "$HOME/backup-`date +%Y`" 2>/dev/null
55 sudo cdrecord -tao -data speed=4 back.iso 2>/dev/null
57 echo "Error. Is the CD in the drive?" >&2
59 echo "Yearly backup finished. Please put a blank CD in the drive." >&2
60 elif [ "$d" = 01 -o "$d" = 08 -o "$d" = 16 -o "$d" = 23 ]; then
61 s="`sudo cdrecord -msinfo 2>/dev/null`"
64 mkisofs -r -J -o back.iso -M /dev/cdr -C "$s" "$HOME/backup-`date +%Y`"
65 sudo cdrecord -tao -data -multi speed=4 back.iso || \
66 echo "CD burning failed." >&2
68 echo "Error. Is the CD in the drive?" >&2
73 rm -rf /tmp/.critical-$LOGNAME-$$