Skip to content

Instantly share code, notes, and snippets.

@sohooo
Created March 24, 2012 15:30
Show Gist options
  • Save sohooo/2184327 to your computer and use it in GitHub Desktop.
Save sohooo/2184327 to your computer and use it in GitHub Desktop.
This little script creates incremental rsync backups from my external Lightroom Library (but could be anything) to another external harddrive. Backups are important, you know.
#!/bin/bash
# This little script creates incremental rsync backups from my
# external Lightroom Library (but could be anything) to another
# external harddrive. Backups are important, you know.
# The result looks like this:
#
# 20120105-1759
# 20120107-1928
# 20120107-2000
# 20120323-1859
# current -> /Volumes/Phobos/Lightroom/20120323-1859
# These rotating backups are possible with rsync's `--link-dest`
# parameter. Look here for more:
# http://www.sanitarium.net/golug/rsync_backups_2010.html
# Settings
# -------------------------------------------
# misc
label=$(date "+%Y%m%d-%H%M")
# backup paths
backup_path="/Volumes/Phobos/Lightroom"
source_path="/Volumes/Vault/Lightroom"
inc_backup="${backup_path}/inc_backup-${label}"
full_backup="${backup_path}/${label}"
current_backup="${backup_path}/current"
# Checks
# -------------------------------------------
if [[ ! -e $source_path ]]; then
echo "Lightroom source not available"
echo "this should be here:"
echo $source_path
exit 1
fi
# Backup
# -------------------------------------------
# We exclude the Lightroom Previews file (that's
# the `--exclude` line) to reduce backup size.
time rsync -avz \
--progress \
--stats \
--exclude='*.lrdata' \
--link-dest=${current_backup} \
${source_path}/ \
$inc_backup
if [[ $? == 0 ]]; then
echo "syncing successful"
else
echo "syncing error; abort"
exit 2
fi
echo "renaming backup folder"
mv -v $inc_backup $full_backup
echo "linking to current backup"
rm $current_backup
ln -sv $full_backup $current_backup
echo "total backup size"
du -sh $backup_path
echo
echo "your stuff is safe now,"
echo "enjoy this warm and fuzzy feeling"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment