Is the only way to get the latest revision number to run “duplicacy list” and wait for it to finish? I have a backup with almost 1000 revisions and it was very slow. So I wrote the following bash script which will use a binary search to find the most recent revision a little more quickly. It seems to work so I thought I would share it here in case others might find it useful.
#!/usr/bin/env bash
find_latest_duplicacy_revision() {
starting_guess=${1:-400}
found=0
last_existing=0
last_failing=0
rev=$starting_guess
while (( found == 0 )); do
echo "trying $rev"
if duplicacy list -r $rev; then
last_existing=$rev
else
last_failing=$rev
fi
if (( last_existing == last_failing - 1 )); then
found=$last_existing
elif (( last_failing == 0 )); then
(( rev = rev * 2 ))
else
(( rev = (last_failing + last_existing) / 2 ))
fi
done
if (( found > 0 )); then
echo "found latest revision: $found"
else
echo "unable to find latest revision"
fi
}
find_latest_duplicacy_revision 500