Last active
December 17, 2015 01:49
-
-
Save shkm/5531679 to your computer and use it in GitHub Desktop.
Bootable OS X backups with rsync. Based on Nicolas Gallagher's script (http://nicolasgallagher.com/mac-osx-bootable-backup-drive-with-rsync/).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- .Spotlight-*/ | |
- .Trashes | |
- .DocumentRevisions-*/ | |
- /.dbfseventsd | |
- .fseventsd/ | |
- /tmp/* | |
- /Network/* | |
- /cores/* | |
- /afs/* | |
- /automount/* | |
- /private/tmp/* | |
- /private/var/run/* | |
- /private/var/spool/postfix/* | |
- /private/var/vm/* | |
- /Previous Systems.localized | |
- /Volumes/* | |
- */.Trash | |
- .DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Bootable disk backup | |
# Requires rsync 3 | |
# Should be run as root | |
DST="/Volumes/DESTINATION/" | |
SRC="/" | |
EXCLUDE="/path/to/exclude_file" | |
RSYNC="/usr/local/bin/rsync" | |
PROG="SystemMirror" | |
# --acls update the destination ACLs to be the same as the source ACLs | |
# --archive turn on archive mode (recursive copy + retain attributes) | |
# --delete delete any files that have been deleted locally | |
# --delete-excluded delete any files (on DST) that are part of the list of excluded files | |
# --exclude-from reference a list of files to exclude | |
# --hard-links preserve hard-links | |
# --one-file-system don't cross device boundaries (ignore mounted volumes) | |
# --sparse handle spare files efficiently | |
# --verbose increase verbosity | |
# --xattrs update the remote extended attributes to be the same as the local ones | |
if [ ! -r "$SRC" ]; then | |
logger -t $PROG "Source $SRC not readable - Cannot start the sync process" | |
exit; | |
fi | |
if [ ! -w "$DST" ]; then | |
logger -t $PROG "Destination $DST not writeable - Cannot start the sync process" | |
exit; | |
fi | |
logger -t $PROG "Start rsync" | |
$RSYNC --acls \ | |
--archive \ | |
--delete \ | |
--delete-excluded \ | |
--exclude-from=$EXCLUDE \ | |
--hard-links \ | |
--one-file-system \ | |
--sparse \ | |
--verbose \ | |
--xattrs \ | |
"$SRC" "$DST" | |
logger -t $PROG "End rsync" | |
# Make the backup bootable | |
bless -folder "$DST"/System/Library/CoreServices | |
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>Label</key> | |
<string>org.rsync.mirror.system</string> | |
<key>LowPriorityIO</key> | |
<true/> | |
<key>Nice</key> | |
<integer>1</integer> | |
<key>Program</key> | |
<string>/PATH/TO/MIRROR/SCRIPT</string> | |
<key>StartCalendarInterval</key> | |
<dict> | |
<key>Hour</key> | |
<integer>15</integer> | |
<key>Minute</key> | |
<integer>00</integer> | |
</dict> | |
</dict> | |
</plist> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment