From 34b58163e990bab5045345981a8dce5f575faa36 Mon Sep 17 00:00:00 2001 From: David Tomaschik Date: Thu, 3 Sep 2015 18:32:44 -0700 Subject: [PATCH] Add backup script. --- bin/backup.sh | 29 +++++++++++++++++++++++++++++ dotfiles/rsync_ignore | 7 +++++++ 2 files changed, 36 insertions(+) create mode 100755 bin/backup.sh create mode 100644 dotfiles/rsync_ignore diff --git a/bin/backup.sh b/bin/backup.sh new file mode 100755 index 0000000..2e5c80a --- /dev/null +++ b/bin/backup.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +set -o nounset +set -o errexit + +DEFAULT=`echo /media/${USER}/[bB]ackup/${USER}/` +DEST="${1:-${DEFAULT}}" + +function verify_dest { + arr=($1) + items=${#arr[@]} + if [ $items -ne 1 ] ; then + echo "Bad count of backup destinations." > /dev/stderr + exit 1 + fi + dir="$1" + end=$((${#dir}-1)) + last="${dir:$end:1}" + if [ "$last" != "/" ] ; then + echo -n "Destination $dir does not end in a /, " > /dev/stderr + echo "this is probably not what you want!" > /dev/stderr + echo "Press a key to continue, or CTRL-C to cancel." > /dev/stderr + read + fi +} + +verify_dest "$DEST" + +rsync -Hax --delete-before --exclude-from="$HOME/.rsync_ignore" "${HOME}/" "$DEST" diff --git a/dotfiles/rsync_ignore b/dotfiles/rsync_ignore new file mode 100644 index 0000000..399c6af --- /dev/null +++ b/dotfiles/rsync_ignore @@ -0,0 +1,7 @@ +tmp +Downloads +.cache +.local/share/Trash +.wine +.thumbnails +.histfile