Skip to content

Instantly share code, notes, and snippets.

@mkhl
Created March 4, 2010 08:48
Show Gist options
  • Save mkhl/321548 to your computer and use it in GitHub Desktop.
Save mkhl/321548 to your computer and use it in GitHub Desktop.
Simple backup to an external volume with `bup`
#!/bin/bash
set -e
VOLUME=Tigh
function die {
echo "`basename -- "$0"`:" "$@" 1>&2
exit 1
}
if [[ ! -d "/Volumes/$VOLUME" ]]; then
die "volume \`$VOLUME' not mounted"
fi
if ! command -v "bup" &>/dev/null; then
die "command \`bup' not found"
fi
export BUP_DIR="/Volumes/$VOLUME/.bup"
bup index -u "$HOME"
bup save -n "`id -un`" "$HOME"
#!/bin/bash
set -e
export BUP_DIR="/Volumes/Tigh/.bup"
export GIT_DIR="$BUP_DIR"
for file; do
bupf="`realpath "$file"`.bup"
egrep -q "^$HOME" <<<"$bupf"
sha1="$(git ls-tree `id -un` -- "${bupf#/}" | cut -c13-52)"
bup join "$sha1" > "$bupf"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment