rsync – backup.sh
#!/bin/bash
# backup-script for rsync/osx
#
# version 1.12
# Mario Fischer ich@mariofischer.name
#
#
# ----- Set Default Parameters -----
#
# folders to backup..
src_folders="/Users/mario/ /Applications /Library"
# backup-target
dest_folder="/Volumes/backup/"
# location of hfs-enabled rsync-command
rsync_cmd="/opt/local/bin/rsync"
# excluded folders, separate with space, terminate with "/"
exclude_folders="Safari/Icons/ Caches/ .Trash/"
# rsync options
rsync_options="--dry-run --relative -a --eahfs --delete --force " # --force --delete --delete-excluded"
#
# ----- Check if params are reasonable -----
#
if [[ $rsync_cmd == "" ]]; then
echo "no command given"
exit 1
fi
if [[ ! -x $rsync_cmd ]]; then
echo "$rsync_cmd is not executable"
exit 1
fi
if [[ ! -d $dest_folder ]]; then
echo "$dest_folder is not a directory"
exit 1
fi
if [[ ! -w $dest_folder ]]; then
echo "$dest_folder is not writable"
exit 1
fi
# build exclude-options
for path in $exclude_folders; do
exc_options="$exc_options--exclude \"$path\" "
done
# build cmdline
cmd="sudo $rsync_cmd $rsync_options $additional_options $exc_options"
#
# ----- do rsync -----
#
for path in $src_folders; do
cmd_here="$cmd $path $dest_folder"
echo `date`" >> calling rsync for $path "
eval $cmd_here
echo " "
done
echo "backup complete."
exit 0
Backup Script using rsyncx
The Code is below, should be self-explanatory.
More information found here:
blog.plasticsfuture.org »