This is a quick tut on how to back up your flash drive. I have a 4gb cruzer mini and I use it all the time, and it took me awhile to assemble it the way I like for working on macs all over campus so losing the drive is not as much of a drag as would be rebuilding all the tools and updaters and notes I have on there. So I use the built-in Rsync tool to back up my flash drive.

This is not for the new users, this does require a little experience with the computer.

Here is a simple bash script to type in. You can edit it in using Pico or any basic word processor. It will run automatically when double clicked if you end the filename with ".command". You will probably need to chmod u+x the script for it to run.

You will want to change the top variable from "Flash" to the name of your flash drive. I suggest using a basic name that does not include symbols or spaces. Numbers are OK. If you use odd characters, it will probably break the script.

It will create a folder in your home that is the same name as the flash drive. After it backs up your flash drive, it will write-lock it. I did this because a few times I have accidentally made updates to documents on my backup ("I'll copy those to the flash drive later") and then of course I ran a sync instead later and zapped my changes. So now I can only change the original on the flash drive.

Rsync is a true synchronizer, and will not copy anything you haven't changed. If you have a fast flash drive this will only take about 15 seconds for most people. It takes 20-60 seconds here depending on how much I have changed on my 4gb drive. Because the "--delete" flag is used, it WILL delete files on the backup that are not on the flash drive. So if you get rid of something on the flash drive, it will go away from the backup next sync. This is not a full featured backup - if you accidentally change or delete something and then (after syncing) realize your mistake, it's too late. If you'd rather it not delete files, just remove that part of the command, but be warned that your backup may grow in size over the months with all your old junk hanging around.
code:

#!/bin/bash

# the name of the flash drive to sync.  Probably a good idea to keep the name free of symbols and spaces or this sript may break
flashdrive="Flash"

# this is the temp file where the error log is stored.  most people don't need to worry about this
errorlog="rsyncerrors"

clear
echo

if [ ! -d /Volumes/$flashdrive ] ; then
  echo "Attach $flashdrive and try again!"
  exit
fi

if [ ! -d /Volumes/$flashdrive/.Trashes ] ; then
  echo "Possible broken symlnk in Volumes - fix and try again!"
  exit
fi

echo "Synchronizing $flashdrive to Macintosh..."
echo

# prepare to make a temp file to store sync results in
if [ ! -d /tmp/$UID ] ; then
  mkdir /tmp/$UID
fi
if [ -f /tmp/$UID/$errorlog ] ; then
  rm /tmp/$UID/$errorlog
fi
if [ -f /tmp/$UID/$errorlog ] ; then
  echo "Failed to delete temp file"
  echo /tmp/$UID/$errorlog
  exit
fi

# create the backup folder if this is the first run
if [ ! -d ~/$flashdrive ] ; then
  echo "Creating backup folder..."
  mkdir ~/$flashdrive
  if [ ! -d ~/$flashdrive ] ; then
    echo "Failed to create backup folder!"
    exit
  fi
fi

# allow writing to the backup on the mac
echo "Unlocking the backup..."
chmod -R u+w ~/$flashdrive
# then back it up
echo "Synchronizing files..."
rsync -ax -eahfs --delete --progress --exclude=.Trashes --exclude=".Spotlight-V100" --exclude=".TemporaryItems" --exclude="DATA XFER" /Volumes/$flashdrive ~ | grep "failed:" >> /tmp/$UID/$errorlog
# and finally disable writing to the backup on the mac - this way we can't change the backup and get it overwritten by the next sync
echo "Locking the backup..."
chmod -R ugo-w ~/$flashdrive

clear
echo
echo "Sync complete!"
echo

if [ -s /tmp/$UID/$errorlog ] ; then
  echo "               "
  echo " *****         "
  echo "*     *        "
  echo "* x x *        "
  echo "*  .  *  Uh Oh!"
  echo "*  o  *        "
  echo "*     *        "
  echo " *****         "
  echo "               "
  echo "Errors were encounterd!  Here is the list:"
  echo
  cat /tmp/$UID/$errorlog
else
  echo "       __________________"
  echo " .----|                  |"
  echo " |    |      DONE!       |"
  echo " |    |                  |"
  echo " '----'__________________"
  echo ""
  echo ""
  echo ""
  echo ""
  rm /tmp/$UID/$errorlog
fi
Although I code a lot, bash is not my area of expertise so don't be surprised if you find improvements or bugfixes in this.

If you find it is complaining about the "-eahfs" flag, you have somehow acquired the wrong version of rsync and it does not support resource forks. (I know v2.1 does NOT work) If this is not a problem for you, (mangling OS 9 apps and custom icons mostly) then just remove that flag from the command in the script. You can check for your version of rsync easily with the command below. RsyncX on versiontracker, an update to Rsync, does NOT support resource forks. The one bundled with tiger works fine.

VirtualBook:~ virtual1$ rsync --version
rsync version 2.6.0 protocol version 27

I've lost my flash drive once now, and having the backup handy was very nice.