Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Backup script for 10.4' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Backup script for 10.4
Authored by: rflo on Jun 28, '05 10:28:39AM
Here's a script for multi-volume backups on MacOS 10.4. Usage is

backup [-cd] [-m yyyy-mm-dd] [files]
The default files are specified in the script and should be modified as needed, the default medium is DVD, and the default backup is from the epoch. The -cd option changes the medium to CD, and the -m option allows you to do an incremental backup from the date specified.

#!/bin/sh
# ron@18james.com, 26 Jun 2005

day=`date "+%y%m%d"`
folder=/tmp/backup-$day
files="Users/heather Users/ron usr/local/web usr/local/pgms"
length=4550000
medium="DVD"

while [ $# -gt 0 ]
  do
  case $1 in
      -m) shift; arg="--newer-mtime=$1"; shift;;
      -h) echo "usage: backup [-cd] [-m yyyy-mm-dd] [files]"; exit;;
      -cd) length=680000; medium="CD"; shift;;
      *) files="$@"; break;;
  esac
  done

echo -n "Ready to backup $files to $medium? "
while read yn
  do case $yn in
      y*|Y*)  break ;;
      n*|N*)  exit 1 ;;
      *)  echo -n "Yes or no? " ;;
  esac
  done

echo "When tar asks for a new volume, drag $folder to a burn folder
in the Finder and burn the $medium.  Then delete $folder/backup.tar
before pressing return to restart tar for the next $medium."

mkdir $folder
cd /
sudo tar -L $length $arg --exclude=Users/*/Library/Caches --exclude=Users/*/.Trash -cvpMf $folder/backup.tar $files 
To use the backup script unattended, write a short script that will move /tmp/backup-/backup.tar to an archival location with a unique filename, such as the current time. Invoke that script in the tar command with "--new-volume-script=". You may also need to run the tar command as "tar ... < `yes`". (I haven't bothered with unattended operation because the tar archiving is very quick compared to the s-l-o-w burning of DVDs.)

---
Ronald Florence

[ Reply to This | # ]