Created
February 26, 2014 19:33
-
-
Save tovbinm/9236724 to your computer and use it in GitHub Desktop.
Backup Mac using rsync
This file contains hidden or 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 | |
/afs/* | |
/automount/* | |
/cores/* | |
/dev/* | |
/Network/* | |
/private/tmp/* | |
/private/var/run/* | |
/private/var/spool/postfix/* | |
/private/var/vm/* | |
/Previous Systems.localized | |
/tmp/* | |
/Volumes/* | |
*/.Trash | |
.DS_Store |
This file contains hidden or 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 | |
# Disc backup script | |
# Requires rsync 3 | |
# Ask for the administrator password upfront | |
sudo -v | |
DST="/Volumes/backup/destination/folder/" | |
SRC="/" | |
EXCLUDE="$HOME/.backupignore" | |
PROG=$0 | |
# --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 sparse files efficiently | |
# --verbose increase verbosity | |
# --xattrs update the remote extended attributes to be the same as the local ones | |
if [ ! -r "$SRC" ]; then | |
echo "Source $SRC not readable - Cannot start the sync process" | |
exit; | |
fi | |
#if [ ! -w "$DST" ]; then | |
# echo "Destination $DST not writeable - Cannot start the sync process" | |
# exit; | |
#fi | |
echo "Start rsync" | |
sudo rsync --acls \ | |
--archive \ | |
--delete \ | |
--delete-excluded \ | |
--exclude-from=$EXCLUDE \ | |
--hard-links \ | |
--one-file-system \ | |
--sparse \ | |
--verbose \ | |
--xattrs \ | |
"$SRC" "$DST" | |
echo "End rsync" | |
# Make the backup bootable | |
sudo bless -folder "$DST"System/Library/CoreServices | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment