hacks/osxbackup/rsyncbackup.command

193 lines
6.7 KiB
Plaintext
Raw Normal View History

2013-05-14 22:24:10 +00:00
#!/bin/bash
2019-08-08 10:26:42 +00:00
# 345678901234567892123456789312345678941234567895123456789612345678971234567898
2013-05-14 22:24:10 +00:00
# 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`"
BACKUPDEST=${BACKUPDEST:-"/Volumes/ExternalBackup/sneak.backup"}
2019-08-08 10:26:42 +00:00
RSYNC_SKIP_COMPRESS="3fr/3g2/3gp/3gpp/7z/aac/ace/amr/apk/appx/appxbundle"
RSYNC_SKIP_COMPRESS+="/arc/arj/arw"
2018-10-31 07:08:18 +00:00
RSYNC_SKIP_COMPRESS+="/asf/avi/bz2/cab/cr2/crypt[5678]/dat/dcr/deb/dmg/drc/ear"
RSYNC_SKIP_COMPRESS+="/erf/flac/flv/gif/gpg/gz/iiq/iso/jar/jp2/jpeg/jpg/k25/kdc"
2019-08-08 10:26:42 +00:00
RSYNC_SKIP_COMPRESS+="/lz/lzma/lzo/m4[apv]/mef/mkv/mos/mov/mp[34]/mpeg"
RSYNC_SKIP_COMPRESS+="/mp[gv]/msi"
2018-10-31 07:08:18 +00:00
RSYNC_SKIP_COMPRESS+="/nef/oga/ogg/ogv/opus/orf/pef/png/qt/rar/rpm/rw2/rzip/s7z"
RSYNC_SKIP_COMPRESS+="/sfx/sr2/srf/svgz/t[gb]z/tlz/txz/vob/wim/wma/wmv/xz/zip"
2019-08-08 10:26:42 +00:00
RSYNC="rsync"
RSYNC_TRY="$HOME/Library/Homebrew/bin/rsync"
2020-02-15 21:38:59 +00:00
if which brew >/dev/null 2>&1 ; then
RSYNC_TRY="$(brew --prefix)/bin/rsync"
fi
2019-08-08 10:26:42 +00:00
if [[ -e "$RSYNC_TRY" ]]; then
RSYNC="$RSYNC_TRY"
fi
2018-10-31 07:08:18 +00:00
#OPTS="-rlptDPSyzh --numeric-ids --no-owner --no-group --delete-excluded --delete"
2019-08-08 10:26:42 +00:00
2018-10-31 07:08:18 +00:00
OPTS=""
2019-08-08 10:26:42 +00:00
2018-10-31 07:08:18 +00:00
OPTS+=" -avP --skip-compress=$RSYNC_SKIP_COMPRESS"
2019-03-21 01:01:13 +00:00
OPTS+=" --numeric-ids --no-owner --no-group --delete-excluded --delete-after"
2013-05-14 22:24:10 +00:00
RE=""
2019-08-08 10:26:42 +00:00
2018-10-31 07:08:18 +00:00
RE+=" --exclude=.bundle/"
2019-08-08 10:26:42 +00:00
RE+=" --exclude=.cache/"
RE+=" --exclude=/.cpan/build/"
RE+=" --exclude=/.cpan/sources/"
RE+=" --exclude=/.docker/"
2022-12-10 01:36:30 +00:00
RE+=" --exclude=/.local/share/containers/podman/machine/"
2019-08-08 10:26:42 +00:00
RE+=" --exclude=/.dropbox/"
RE+=" --exclude=/.minikube/cache/"
2021-10-30 00:41:29 +00:00
RE+=" --exclude=/Applications/Fortnite/"
2013-05-14 22:24:10 +00:00
RE+=" --exclude=/Desktop/" # desktop is like a visible tempdir.
2019-08-08 10:26:42 +00:00
RE+=" --exclude=/Documents/Dropbox/.dropbox.cache/"
RE+=" --exclude=/Documents/Steam?Content/"
2018-10-29 20:18:23 +00:00
RE+=" --exclude=/Downloads/"
2013-05-14 22:24:10 +00:00
RE+=" --exclude=/Library/Application?Support/Ableton/"
2019-08-08 10:26:42 +00:00
RE+=" --exclude=/Library/Application?Support/Adobe/Adobe?Device?Central?CS4/"
RE+=" --exclude=/Library/Application?Support/CrossOver?Games/"
RE+=" --exclude=/Library/Application?Support/Evernote/" # syncs to cloud
2013-05-14 22:24:10 +00:00
RE+=" --exclude=/Library/Application?Support/InsomniaX/"
2019-08-08 10:26:42 +00:00
RE+=" --exclude=/Library/Application?Support/MobileSync/"
2013-05-14 22:24:10 +00:00
RE+=" --exclude=/Library/Application?Support/SecondLife/cache/"
2019-08-08 10:26:42 +00:00
RE+=" --exclude=/Library/Application?Support/Steam/SteamApps/"
2013-05-14 22:24:10 +00:00
RE+=" --exclude=/Library/Application?Support/SyncServices/"
2022-01-21 06:46:18 +00:00
RE+=" --exclude=/Library/Application?Support/protonmail/bridge/cache"
2022-12-10 01:36:30 +00:00
RE+=' --exclude=/Library/Application?Support/Syncthing/index-*'
2022-01-21 06:46:18 +00:00
RE+=" --exclude=/Library/Metadata"
2019-08-08 10:26:42 +00:00
RE+=" --exclude=/Library/Caches/"
RE+=" --exclude=/Library/Containers/com.docker.docker/"
2023-01-13 10:15:53 +00:00
RE+=" --exclude=/Library/Group?Containers/group.com.apple.secure-control-center-preferences"
2013-05-14 22:24:10 +00:00
RE+=" --exclude=/Library/Cookies/"
2019-08-08 10:26:42 +00:00
RE+=" --exclude=/Library/Developer/"
2021-10-30 00:41:29 +00:00
RE+=" --exclude=/Library/Google/GoogleSoftwareUpdate/"
2019-08-08 10:26:42 +00:00
RE+=" --exclude=/Library/Homebrew/"
RE+=" --exclude=/Library/Logs/"
RE+=" --exclude=/Library/Mail/" # keep your mail on the server!
RE+=" --exclude=/Library/Mail?Downloads/"
2021-10-30 00:41:29 +00:00
RE+=" --exclude=/Library/Parallels/"
2023-01-13 10:15:53 +00:00
RE+=" --exclude=/Library/Suggestions/"
2019-08-08 10:26:42 +00:00
RE+=" --exclude=/Library/Preferences/Macromedia/Flash?Player/"
2013-05-14 22:24:10 +00:00
RE+=" --exclude=/Library/Preferences/SDMHelpData/"
2019-08-08 10:26:42 +00:00
RE+=" --exclude=/Library/PubSub/"
RE+=" --exclude=/Library/Safari/"
RE+=" --exclude=/Library/Safari/HistoryIndex.sk"
2021-10-30 00:41:29 +00:00
RE+=" --exclude=/Library/Syncthing/folders/" # syncthing is its own backup
RE+=" --exclude=/Library/VoiceTrigger/SAT"
2019-08-08 10:26:42 +00:00
RE+=" --exclude=/Library/iTunes/iPad?Software?Updates/"
RE+=" --exclude=/Library/iTunes/iPhone?Software?Updates/"
2022-12-10 01:36:30 +00:00
RE+=" --exclude=/Movies/CacheClip/"
RE+=" --exclude=/Movies/ProxyMedia/"
2019-08-08 10:26:42 +00:00
RE+=" --exclude=/Music/iTunes/Album?Artwork/"
RE+=" --exclude=/Pictures/iPod?Photo?Cache/"
2013-05-14 22:24:10 +00:00
RE+=" --exclude=/Receivd/"
2018-10-29 20:18:23 +00:00
2013-05-14 22:24:10 +00:00
MINRE=""
MINRE+=" --exclude=/.fseventsd/"
MINRE+=" --exclude=/.Spotlight-V100/"
MINRE+=" --exclude=/.Trash/"
MINRE+=" --exclude=/.Trashes/"
MINRE+=" --exclude=/tmp/"
MINRE+=" --exclude=/.TemporaryItems/"
MINRE+=" --exclude=/.rnd/"
MINRE+=" --exclude=.DS_Store"
RE+=" ${MINRE}"
2019-10-31 13:31:28 +00:00
echo "beginning backup to '$BACKUPDEST'..."
2013-05-14 22:24:10 +00:00
RETVAL=255
while [ $RETVAL -ne 0 ]; do
2018-10-31 07:08:18 +00:00
$RSYNC $OPTS $RE ${HOME}/ ${BACKUPDEST}/home.$(whoami)/
2013-05-14 22:24:10 +00:00
RETVAL=$?
2018-10-31 07:08:18 +00:00
sleep 1;
2013-05-14 22:24:10 +00:00
done
2018-10-31 07:08:18 +00:00
RE=""
RE+=" --exclude=/.DS_Store"
RE+=" --exclude=/App?Store.app"
RE+=" --exclude=/Automator.app"
RE+=" --exclude=/Books.app"
RE+=" --exclude=/Calculator.app"
RE+=" --exclude=/Calendar.app"
RE+=" --exclude=/Chess.app"
RE+=" --exclude=/Contacts.app"
RE+=" --exclude=/DVD?Player.app"
RE+=" --exclude=/Dashboard.app"
RE+=" --exclude=/Dictionary.app"
RE+=" --exclude=/FaceTime.app"
RE+=" --exclude=/Font?Book.app"
RE+=" --exclude=/Game?Center.app"
RE+=" --exclude=/GarageBand.app"
RE+=" --exclude=/Home.app"
RE+=" --exclude=/Image?Capture.app"
RE+=" --exclude=/Install?OS?X?El?Capitan.app"
RE+=" --exclude=/Install?OS?X?Yosemite.app"
RE+=" --exclude=/Keynote.app"
RE+=" --exclude=/Launchpad.app"
RE+=" --exclude=/Mail.app"
RE+=" --exclude=/Maps.app"
RE+=" --exclude=/Messages.app"
RE+=" --exclude=/Mission?Control.app"
RE+=" --exclude=/News.app"
RE+=" --exclude=/Notes.app"
RE+=" --exclude=/Numbers.app"
RE+=" --exclude=/Pages.app"
RE+=" --exclude=/Photo?Booth.app"
RE+=" --exclude=/Photos.app"
RE+=" --exclude=/Preview.app"
RE+=" --exclude=/QuickTime?Player.app"
RE+=" --exclude=/Reminders.app"
RE+=" --exclude=/Safari.app"
RE+=" --exclude=/Siri.app"
RE+=" --exclude=/Spotify.app"
RE+=" --exclude=/Steam.app"
2019-08-08 10:26:42 +00:00
RE+=" --exclude=/Stocks.app"
2018-10-31 07:08:18 +00:00
RE+=" --exclude=/Stickies.app"
RE+=" --exclude=/System?Preferences.app"
RE+=" --exclude=/TextEdit.app"
RE+=" --exclude=/Time?Machine.app"
RE+=" --exclude=/Utilities/Activity?Monitor.app"
RE+=" --exclude=/Utilities/AirPort?Utility.app"
RE+=" --exclude=/Utilities/AppleScript?Editor.app"
RE+=" --exclude=/Utilities/Audio?MIDI?Setup.app"
RE+=" --exclude=/Utilities/Bluetooth?File?Exchange.app"
RE+=" --exclude=/Utilities/Boot?Camp?Assistant.app"
RE+=" --exclude=/Utilities/ColorSync?Utility.app"
RE+=" --exclude=/Utilities/Console.app"
RE+=" --exclude=/Utilities/Digital?Color?Meter.app"
RE+=" --exclude=/Utilities/DigitalColor?Meter.app"
RE+=" --exclude=/Utilities/Disk?Utility.app"
RE+=" --exclude=/Utilities/Grab.app"
RE+=" --exclude=/Utilities/Grapher.app"
RE+=" --exclude=/Utilities/Keychain?Access.app"
RE+=" --exclude=/Utilities/Migration?Assistant.app"
RE+=" --exclude=/Utilities/Screenshot.app"
RE+=" --exclude=/Utilities/Script?Editor.app"
RE+=" --exclude=/Utilities/System?Information.app"
RE+=" --exclude=/Utilities/Terminal.app"
RE+=" --exclude=/Utilities/VoiceOver?Utility.app"
RE+=" --exclude=/VirtualBox.app"
RE+=" --exclude=/VoiceMemos.app"
RE+=" --exclude=/Xcode.app"
RE+=" --exclude=/iBooks.app"
RE+=" --exclude=/iMovie.app"
RE+=" --exclude=/iTunes.app"
2020-05-26 23:03:55 +00:00
if [[ "$(uname)" = "Darwin" ]]; then
RETVAL=255
while [ $RETVAL -ne 0 ]; do
$RSYNC $OPTS $RE $MINRE /Applications/ ${BACKUPDEST}/Applications/
RETVAL=$?
sleep 1;
done
fi