#!/bin/sh type=$1 args= secret_key=1234ABCD bucket=yourbucketname cd_dev=ATA:1,0,0 cd_mnt=/mnt/cdrom image_dir=/path/to/backup_image iso_file=/path/to/backup.iso case "$type" in full) args="-b $bucket --full" ;; inc | incremental) args="-b $bucket --incremental_from_full" ;; cd) mkdir -p $image_dir || exit 1 args="-d $image_dir --full" ;; *) echo "Usage $0 {full|inc|cd}" exit 1 ;; esac function fail() { echo "process exited with $?" >&2 exit 1 } ./backup.rb $args -n bok -g $secret_key \ --exclude '/path/to/exclude/*' \ --exclude '/another/path/to/exclude/*' \ --exclude '/file/to/exclude' \ /etc \ /usr/local \ /var/backups \ /var/lib/dpkg \ /home \ /root \ /var/spool/cron \ /boot/grub || fail if [[ "$type" == 'cd' ]]; then gpg --export-secret-key $secret_key >$image_dir/key || fail gpg_file=$image_dir/backup_*.tar.gpg md5sum=$(md5sum $gpg_file | tee $gpg_file.md5 | awk '{ print $1 }') mkisofs -r -l -J -o $iso_file $image_dir || fail rm $image_dir/* echo "Generated a $(ls -lh $iso_file | awk '{print $5}') image." echo "Insert a CD-RW disk and press Enter." read foo cdrecord -v -tao -dev=$cd_dev speed=4 blank=fast $iso_file || fail rm $iso_file echo "Checking md5sum of file on CD..." mount $cd_mnt || fail new_md5sum=$(md5sum $cd_mnt/backup_*.tar.gpg | awk '{ print $1 }') if test "$new_md5sum" != "$md5sum"; then echo "md5sums don't match (wanted "$md5sum"; got "$new_md5sum")!" fail fi umount $cd_mnt || fail echo "All done!" eject fi