Skip to content

Instantly share code, notes, and snippets.

@brennanMKE
Last active August 29, 2015 13:56
Show Gist options
  • Save brennanMKE/8813105 to your computer and use it in GitHub Desktop.
Save brennanMKE/8813105 to your computer and use it in GitHub Desktop.
Backup to thumbdrive on a Mac which ignores folders which do not need a backup like Dropbox and GitHub
#!/bin/sh
# set the strict mode
set -e
if [ -d "/Volumes/Thumbdrive" ]; then
if [ ! -d "/Volumes/Thumbdrive/Backups" ]; then
mkdir "/Volumes/Thumbdrive/Backups"
fi
if [ ! -d "/Volumes/Thumbdrive/Backups/MacBook Pro" ]; then
mkdir "/Volumes/Thumbdrive/Backups/MacBook Pro"
fi
rsync -av \
-del \
--exclude "/Documents/VMware/" \
--exclude "/Documents/Projects/GitHub/" \
--exclude "/Documents/Projects/Subversion/" \
--exclude "/Downloads/" \
--exclude "/Dropbox/" \
--exclude "/Library/" \
--exclude "/Music/" \
--exclude ".DS_Store" \
--exclude "/.vagrant.d" \
--exclude "/.Trash" \
--exclude "/.gem" \
--exclude "/.dropbox" \
--exclude "/.cocoapods/" \
~/ "/Volumes/Thumbdrive/Backups/MacBook Pro/"
ls -lsa "/Volumes/Thumbdrive/Backups"
else
echo "Thumbdrive is not connected"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment