Resources‎ > ‎rsync‎ > ‎

How to use rsync



! /bin/bash
# Space-separated list of directories to back up; edit as needed
DIRS="/Users/myname/Work/"

# Options to pass to rsync; edit as needed
# "-E" = copies resource fork data
# "--delete" = destructive backup
#   (i.e. if you delete a local file, it will be deleted
#   on the server at next backup; keeps local+backup synchronized)
# "--update" = update only (don't overwrite newer versions of files)
OPTS="-E --delete --update"

# Backup destination. In this case, it is another hard disk on the same machine.
# Incidentally, it is DOS-formatted, irrelevant here.
# If you wish to back up to a server via ssh, change the line to something like
# BACKUPDIR="remoteusername@someserver.something:/path/to/backup/destination"
BACKUPDIR="remote.machine.usyd.edu.au:~/Work"

# ignore Mac droppings
EXCLUDES="--exclude .DS_Store --exclude .Trash --exclude Cache --exclude Caches"

# Build the actual command
# NOTE the specific path to the "special" version of rsync
COMMAND="rsync -rtzv $OPTS $EXCLUDES $DIRS $BACKUPDIR"

# Informative output
echo About to run:
echo $COMMAND
echo Please do not close this window until it is finished.

# DO IT!
$COMMAND

echo Done.

# the end.

Comments