Skip to content

Instantly share code, notes, and snippets.

@josephruscio
Forked from necolas/rsync_backup
Last active December 10, 2015 18:08
Show Gist options
  • Save josephruscio/4472376 to your computer and use it in GitHub Desktop.
Save josephruscio/4472376 to your computer and use it in GitHub Desktop.
#!/bin/sh
#set -x
PROG=$0
# Install an updated rsync using homebrew with the instructions here:
# http://blog.jm3.net/2012/07/30/os-x-rsync
RSYNC="/usr/local/bin/rsync"
SRC="/"
DST="/Volumes/Joe's Backup"
# Shutdown time machine if it's running
/usr/bin/logger -t $PROG "Disable Time Machine"
sudo tmutil disable
# Sync the backup disk
/usr/bin/logger -t $PROG "Start rsync"
# rsync options
# -v increase verbosity
# -a turns on archive mode (recursive copy + retain attributes)
# -x don't cross device boundaries (ignore mounted volumes)
# -E preserve executability
# -S handle sparse files efficiently
# --delete delete deletes any files that have been deleted locally
# --exclude-from reference a list of files to exclude
sudo $RSYNC -vaxE -S --delete --exclude-from=$HOME/.rsync_excludes.txt "$SRC" "$DST"
/usr/bin/logger -t $PROG "End rsync"
# Re-enable time machine
/usr/bin/logger -t $PROG "Disable Time Machine"
sudo tmutil enable
# make the backup bootable
sudo bless -folder "$DST"/System/Library/CoreServices
exit 0
.Spotlight-*/
.Trashes
/tmp/*
/Network/*
/cores/*
/afs/*
/automount/*
/private/tmp/*
/private/var/run/*
/private/var/spool/postfix/*
/private/var/vm/*
/Previous Systems.localized
/Volumes/*
*/.Trash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment