Skip to content

Instantly share code, notes, and snippets.

@abdul
Last active August 29, 2015 14:15
Show Gist options
  • Select an option

  • Save abdul/66e1bba9077c2a493ccb to your computer and use it in GitHub Desktop.

Select an option

Save abdul/66e1bba9077c2a493ccb to your computer and use it in GitHub Desktop.
A rsync incremental backup script which backs all data on a non-bootable partition. This script doesn't delete anything on destination/target disk.
.Spotlight-*/
.DocumentRevisions-*/
.MobileBackups/
.Trashes
/afs/*
/automount/*
/cores/*
/dev/*
/Network/*
/private/tmp/*
/private/var/run/*
/private/var/spool/postfix/*
/private/var/vm/*
/Previous Systems.localized
/tmp/*
/Volumes/*
*/.Trash
#!/bin/bash
# Source Script: https://github.com/necolas/dotfiles/blob/master/bin/backup
# Original Author: Nicolas Gallagher (http://nicolasgallagher.com)
# Modified by: Abdul Qabiz
# The script has been modified to do incremental data (non bootable) backup.
# The script doesn't delete anything on destination ($DST).
# Disc backup script
# Requires rsync 3
# Ask for the administrator password upfront
sudo -v
# IMPORTANT: Make sure you update the `DST` variable to match the name of the
# destination backup drive
DST="/Volumes/MacintoshHD_Archive/"
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
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"
sudo rsync --acls \
--archive \
--exclude-from=$EXCLUDE \
--hard-links \
--one-file-system \
--sparse \
--verbose \
--xattrs \
"$SRC" "$DST"
logger -t $PROG "End rsync"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment