Skip to content

Instantly share code, notes, and snippets.

@MartinNowak
Created August 15, 2016 09:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MartinNowak/753e29f86eb6543e2269637081212e70 to your computer and use it in GitHub Desktop.
Save MartinNowak/753e29f86eb6543e2269637081212e70 to your computer and use it in GitHub Desktop.
script to convert rdiff-backup to duplicity
#!/bin/bash
set -ueo pipefail
TMPROOT=$(mktemp -d .rdiff_backup_to_duplicity_XXXXXX)
cleanup() {
rm -rf "$TMPROOT";
}
trap cleanup EXIT
RDIFF_BACKUP_REMOTE=$1
DUPLICITY_REMOTE=$2
DUPLICITY_ARGS="--no-encryption"
if [ ! -z "${GPG_KEY:-}" ]; then
DUPLICITY_ARGS="--encrypt-key $GPG_KEY"
fi
RDIFF_ARGS=
if [ ! -z "${REMOTE_TEMPDIR:-}" ]; then
RDIFF_ARGS="--remote-tempdir $REMOTE_TEMPDIR"
fi
backups=$(rdiff-backup --list-increments --parsable-output "$RDIFF_BACKUP_REMOTE" | cut -f1 -d' ')
for ts in $backups; do
rdiff-backup --restore-as-of $ts $RDIFF_ARGS "$RDIFF_BACKUP_REMOTE" "$TMPROOT/rdiff_restored"
duplicity --current-time $ts $DUPLICITY_ARGS "$TMPROOT/rdiff_restored" "$DUPLICITY_REMOTE"
rm -rf "$TMPROOT/rdiff_restored"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment