2011-05-26 12:19:44 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# mac homedir backup script.
|
|
|
|
# by jeffrey paul <sneak@datavibe.net>
|
|
|
|
# 5539 AD00 DE4C 42F3 AFE1 1575 0524 43F4 DF2A 55C2
|
|
|
|
# see README
|
|
|
|
|
|
|
|
NOW="`date +%Y%m%d.%H%M%S`"
|
|
|
|
|
2011-07-05 21:29:44 +00:00
|
|
|
BACKUPDEST=${BACKUPDEST:-"${USER}@jfk1.datavibe.net:backup/"}
|
2011-05-26 12:19:44 +00:00
|
|
|
|
|
|
|
RSYNC="/usr/bin/rsync"
|
2012-01-03 20:39:49 +00:00
|
|
|
OPTS="-rlptDPSyz --no-owner --no-group --delete-excluded --delete"
|
2011-05-26 12:19:44 +00:00
|
|
|
|
|
|
|
RE=""
|
|
|
|
# Dropbox syncs itself just fine:
|
|
|
|
RE+=" --exclude=/Dropbox/"
|
2011-08-22 22:24:08 +00:00
|
|
|
RE+=" --exclude=/Desktop/" # desktop is like a visible tempdir.
|
2011-05-26 12:19:44 +00:00
|
|
|
RE+=" --exclude=/Library/Safari/"
|
|
|
|
RE+=" --exclude=/Downloads/"
|
|
|
|
RE+=" --exclude=/Library/Application?Support/Ableton/"
|
|
|
|
# evernote syncs to its server:
|
|
|
|
RE+=" --exclude=/Library/Application?Support/Evernote/"
|
|
|
|
RE+=" --exclude=/Library/Application?Support/InsomniaX/"
|
|
|
|
RE+=" --exclude=/Music/iTunes/Album?Artwork/"
|
|
|
|
RE+=" --exclude=/Documents/Steam?Content/"
|
|
|
|
RE+=" --exclude=/.cpan/build/"
|
|
|
|
RE+=" --exclude=/.cpan/sources/"
|
|
|
|
RE+=" --exclude=/Library/Logs/"
|
|
|
|
# keep your mail on the server!
|
|
|
|
RE+=" --exclude=/Library/Mail/"
|
|
|
|
RE+=" --exclude=/Library/Mail?Downloads/"
|
|
|
|
RE+=" --exclude=/Library/Application?Support/SecondLife/cache/"
|
|
|
|
RE+=" --exclude=/Library/Caches/"
|
2011-06-13 05:04:38 +00:00
|
|
|
RE+=" --exclude=/Library/Developer/Xcode/DerivedData/"
|
2011-05-26 12:19:44 +00:00
|
|
|
RE+=" --exclude=/Library/iTunes/iPhone?Software?Updates/"
|
|
|
|
RE+=" --exclude=/Library/iTunes/iPad?Software?Updates/"
|
|
|
|
RE+=" --exclude=/Pictures/iPod?Photo?Cache/"
|
|
|
|
RE+=" --exclude=/Library/Application?Support/SyncServices/"
|
|
|
|
RE+=" --exclude=/Library/Application?Support/MobileSync/"
|
|
|
|
RE+=" --exclude=/Library/Application?Support/Adobe/Adobe?Device?Central?CS4/"
|
|
|
|
RE+=" --exclude=/Library/Safari/HistoryIndex.sk"
|
|
|
|
RE+=" --exclude=/Library/Application?Support/CrossOver?Games/"
|
|
|
|
RE+=" --exclude=/Library/Preferences/Macromedia/Flash?Player/"
|
|
|
|
RE+=" --exclude=/Library/PubSub/"
|
2011-07-05 21:29:44 +00:00
|
|
|
# just say no to skynet
|
2011-05-26 12:19:44 +00:00
|
|
|
RE+=" --exclude=/Library/Google/"
|
|
|
|
RE+=" --exclude=/Library/Cookies/"
|
2012-01-03 20:39:49 +00:00
|
|
|
RE+=" --exclude=/Library/Preferences/SDMHelpData/"
|
2011-05-26 12:19:44 +00:00
|
|
|
RE+=" --exclude=/Receivd/"
|
2012-01-03 20:39:49 +00:00
|
|
|
RE+=" --exclude=/Library/Application?Support/Steam/SteamApps/"
|
2011-05-26 12:19:44 +00:00
|
|
|
|
|
|
|
MINRE=""
|
|
|
|
MINRE+=" --exclude=/.fseventsd/"
|
|
|
|
MINRE+=" --exclude=/.Spotlight-V100/"
|
2011-07-05 21:29:44 +00:00
|
|
|
MINRE+=" --exclude=/.Trash/"
|
2011-05-26 12:19:44 +00:00
|
|
|
MINRE+=" --exclude=/.Trashes/"
|
2011-06-16 10:01:16 +00:00
|
|
|
MINRE+=" --exclude=/tmp/"
|
2011-07-05 21:29:44 +00:00
|
|
|
MINRE+=" --exclude=/.TemporaryItems/"
|
|
|
|
MINRE+=" --exclude=/.rnd/"
|
|
|
|
|
|
|
|
RE+=" ${MINRE}"
|
2011-05-26 12:19:44 +00:00
|
|
|
|
|
|
|
# before anything else, backup gpg keys if any:
|
|
|
|
if [ -d ${HOME}/.gnupg ]; then
|
2011-07-05 21:29:44 +00:00
|
|
|
$RSYNC $OPTS -c ${HOME}/.gnupg/ ${BACKUPDEST}/Home/.gnupg/
|
|
|
|
fi
|
|
|
|
|
2011-08-22 22:24:08 +00:00
|
|
|
# high priority stuff first:
|
2011-07-05 21:29:44 +00:00
|
|
|
if [ -d ${HOME}/Development ]; then
|
|
|
|
$RSYNC $OPTS -c ${HOME}/Development/ \
|
|
|
|
${BACKUPDEST}/Home/Development/
|
2011-05-26 12:19:44 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
RETVAL=255
|
|
|
|
while [ $RETVAL -ne 0 ]; do
|
2011-07-05 21:29:44 +00:00
|
|
|
$RSYNC $OPTS $RE ${HOME}/ ${BACKUPDEST}/Home/
|
2011-05-26 12:19:44 +00:00
|
|
|
RETVAL=$?
|
|
|
|
sleep 1;
|
|
|
|
done
|
|
|
|
|
|
|
|
RETVAL=255
|
|
|
|
while [ $RETVAL -ne 0 ]; do
|
2011-07-05 21:29:44 +00:00
|
|
|
$RSYNC $OPTS /Applications/ ${BACKUPDEST}/Applications/
|
2011-05-26 12:19:44 +00:00
|
|
|
RETVAL=$?
|
2012-01-03 20:39:49 +00:00
|
|
|
sleep 1;
|
2011-05-26 12:19:44 +00:00
|
|
|
done
|
|
|
|
|
2012-01-03 20:39:49 +00:00
|
|
|
if [ "${BACKUPDEST::16}" = "/Volumes/imac1tb" ]; then
|
|
|
|
echo "no need to backup to same disk"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
BASE="/Volumes/imac1tb/sneak.data"
|
|
|
|
for DIR in Movies Music Pictures ; do
|
|
|
|
if [ -d "${BASE}/${DIR}/" ]; then
|
|
|
|
RETVAL=255
|
|
|
|
while [ $RETVAL -ne 0 ]; do
|
|
|
|
$RSYNC $OPTS "${BASE}/${DIR}/" "${BACKUPDEST}/${DIR}/"
|
|
|
|
RETVAL=$?
|
|
|
|
sleep 1;
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
done
|