How to check only the latest revision?

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
1 Like

Would not this only work if the repository was never pruned?

The list of snapshots is literally list of files in the target under snapshots\snapshot_id folder.

I can’t imagine getting a folder listing from any remote should take more than few seconds. Maybe connecting directly and fetching the list will be faster.

Also, there is a feature request somewhere for duplicacy to accept -last as revision index, to avoid all of that. Perhaps someone should implemented it and submit PR?

Relevant threads: Struggling with CLI and how to use multiple destinations - #5 by gchen

1 Like

Nobody replied to that feature request.
Yes, “someone should implement it” :smiley:

3 Likes

Has there been any progress on this request?

My use case is exactly the same as some people described above. I run regular backups to a local server using the Web UI and immediately afterwards want to copy the latest revision to an cloud storage for disaster recovery. To save space and money I only keep a subset of revisions in the cloud.

Currently I am using the command line to manually supply the revision number to the copy command. Any of the solutions above (negative index on -r or -last n) would be a great help for me.

2 Likes

Hi, I am also interested in this feature.

1 Like

We are doing daily checks to make sure that the backup has run and we’re just using a bit of Powershell.

C:\Duplicacy\Duplicacy.exe list > C:\Duplicacy\List.txt
Get-Content C:\Duplicacy\List.txt -Last 1