Created
January 16, 2012 20:35
-
-
Save koto/1622842 to your computer and use it in GitHub Desktop.
OSX Snow Leopard bootable backup script with FileVault support (backup will be unencrypted!)
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/sh | |
PROG=$0 | |
# use macports rsync 3.x - Apple's 2.6 hung on sockets | |
RSYNC="/opt/local/bin/rsync" | |
SRC="/" | |
DST="/Volumes/Backup/" | |
FILEVAULT_ACCT="Users/yourusername" | |
# 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 spare files efficiently | |
# --delete delete deletes any files that have been deleted locally | |
# --exclude-from reference a list of files to exclude | |
if [ ! -r "$SRC" ]; then | |
/usr/bin/logger -t $PROG "Source $SRC not readable - Cannot start the sync process" | |
exit; | |
fi | |
if [ ! -w "$DST" ]; then | |
/usr/bin/logger -t $PROG "Destination $DST not writeable - Cannot start the sync process" | |
exit; | |
fi | |
/usr/bin/logger -t $PROG "Start rsync /" | |
sudo $RSYNC -vaxE -S -O --delete --exclude-from=/opt/backup/rsync_excludes.txt "$SRC" "$DST" | |
/usr/bin/logger -t $PROG "End rsync /" | |
/usr/bin/logger -t $PROG "Start rsync $FILEVAULT_ACCT" | |
# copy my FileVault acct (caution - unencrypted!) | |
sudo $RSYNC -vaxE -S -O --delete --exclude-from=/opt/backup/rsync_excludes.txt "$SRC$FILEVAULT_ACCT/" "$DST$FILEVAULT_ACCT/" | |
/usr/bin/logger -t $PROG "End rsync $FILEVAULT_ACCT" | |
/usr/bin/logger -t $PROG "Normalizing $FILEVAULT_ACCT" | |
# tell the system on a backup drive that account is no longer FileVaulted | |
sudo dscl -f "$DST"/var/db/dslocal/nodes/Default / -delete "/Local/Target/$FILEVAULT_ACCT" HomeDirectory | |
# make the backup bootable | |
/usr/bin/logger -t $PROG "Blessing $DST" | |
sudo 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
.Spotlight-*/ | |
.Trashes | |
.fseventsd | |
/tmp/* | |
/Network/* | |
/cores/* | |
/afs/* | |
/automount/* | |
/private/tmp/* | |
/private/var/run/* | |
/private/var/spool/postfix/* | |
/private/var/vm/* | |
/Previous Systems.localized | |
/Volumes/* | |
*/.Trash | |
/Users/.yourusername |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment