Skip to content

Instantly share code, notes, and snippets.

@fnicastri
Forked from artifactsauce/backup_homedir.sh
Created May 20, 2022 10:50
Show Gist options
  • Save fnicastri/443c1ee17c5114b687c62007beb693e0 to your computer and use it in GitHub Desktop.
Save fnicastri/443c1ee17c5114b687c62007beb693e0 to your computer and use it in GitHub Desktop.
Backup script for Mac OS X home directory by rsync
#!/bin/sh
CMDNAME=`basename $0`
while getopts n OPT
do
case $OPT in
"n" ) DRY_RUN="--dry-run" ;;
* ) echo "Usage: $CMDNAME [-n]" 1>&2
exit 1 ;;
esac
done
SOURCE=${HOME}/
TARGET=/Volumes/BACKUP/TARGET
[[ ! -d $TARGET ]] && echo "Target directory does NOT exists." && exit 1
rsync -av --stats --delete-excluded --modify-window=1 $DRY_RUN \
--include "/.ssh/" \
--include "/.dotfiles/" \
--include "/Library/Keychains/*" \
--include "/Library/Application?Support/Adium?2.0/" \
--include "/Library/Application?Support/Cyberduck/" \
--include "/Library/Application?Support/GitHub?for?Mac/" \
--include "/Library/Application?Support/KeyRemap4MacBook/" \
--include "/Library/Application?Support/Postbox/" \
--include "/Library/Application?Support/Sequel?Pro/" \
--include "/Library/Application?Support/Skype/" \
--exclude "/.*" \
--exclude "/perl5/" \
--exclude "/Dropbox/" \
--exclude "/Pictures/" \
--exclude "/Movies/" \
--exclude "/Music/" \
--exclude "/Library/*/*" \
--exclude ".DS_Store" \
--exclude ".localized" \
${SOURCE} ${TARGET}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment