Skip to content

Instantly share code, notes, and snippets.

@cole
Created May 21, 2010 03:50
Show Gist options
  • Select an option

  • Save cole/408433 to your computer and use it in GitHub Desktop.

Select an option

Save cole/408433 to your computer and use it in GitHub Desktop.
#/bin/bash
SCRIPT_NAME="Rsync Stuff"
BACKUP_SERVER="server.strongspace.com"
BACKUP_USER="user"
BACKUP_PATH="/strongspace/user/home/Stuff/"
LOCAL_PATH="/Users/user/Stuff/"
RSYNC_RSH="ssh -c arcfour -o Compression=yes -x"
date=`date +"%Y-%m-%d %H-%M"`
LOG_FILE="/Users/user/Library/Logs/RsyncBackups/${SCRIPT_NAME}-$date.log"
# Sync filesystem
/usr/local/bin/rsync --times --perms --verbose --links --recursive \
--delete --group --owner --one-file-system --hard-links \
"${LOCAL_PATH}" ${BACKUP_USER}@${BACKUP_SERVER}:"${BACKUP_PATH}" >> "${LOG_FILE}" 2>&1
# Notify on success
if [ "$?" = "0" ]; then
/usr/local/bin/growlnotify -p "Moderate" -n "${SCRIPT_NAME}" -m "${SCRIPT_NAME} to ${BACKUP_SERVER} complete"
/usr/bin/logger -i -p daemon.notice Results of backup: - "${SCRIPT_NAME} to ${BACKUP_SERVER} complete"
else # Notify on failure
export error=`tail -n 3 "${LOG_FILE}"`
/usr/local/bin/growlnotify -p "Moderate" -n "${SCRIPT_NAME}" \
-m "${SCRIPT_NAME} to ${BACKUP_SERVER} failed. Error: ${error}"
/usr/bin/logger -i -p daemon.notice Results of backup: - "${SCRIPT_NAME} to ${BACKUP_SERVER} failed"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment