6 echo "Usage: bup import-duplicity [-n]" \
7 "<duplicity target url> <backup name>"
8 echo "-n,--dry-run: just print what would be done"
13 while [ "$1" = "-n" -o "$1" = "--dry-run" ]; do
20 $dry_run "${BUP_MAIN_EXE:=bup}" "$@"
23 duplicity_target_url=$1
26 [ -n "$duplicity_target_url" -a "$#" = 2 ] || usage
28 dup_timestamps=$(duplicity collection-status --log-fd=3 \
29 "$duplicity_target_url" 3>&1 1>/dev/null 2>/dev/null |
30 grep "[[:digit:]][[:digit:]]T" |
32 backups_count=$(echo "$dup_timestamp" | wc -l)
34 echo "$dup_timestamps" |
35 while read dup_timestamp; do
36 timestamp=$(python -c "import time,calendar; " \
37 "print str(int(calendar.timegm(time.strptime('$dup_timestamp', " \
38 "'%Y%m%dT%H%M%SZ'))))")
39 echo "Importing backup from $(date --date=@$timestamp +%c) " \
40 "($counter / $backups_count)" 1>&2
45 echo "Restoring from rdiff-backup..." 1>&2
46 duplicity restore -t "$dup_timestamp" "$duplicity_target_url" "$tmpdir"
49 echo "Importing into bup..." 1>&2
51 bup index -ux -f "$tmpidx" "$tmpdir"
52 bup save --strip --date="$timestamp" -f "$tmpidx" -n "$branch" "$tmpdir"
56 counter=$((counter+1))