Feature Request: support custom B2 download URL in WebUI

So, I opened a pull request for specifying a custom download URL when backing up to B2. This allows you to get free data downloads through Cloudflare. I’m using this now myself and it’s working great.

I figured I could try it with the WebUI by replacing the duplicacy binary and manually adding the keys in the right places to the preferences files. In practice though, it looks like the preferences files are generated as needed and the “keys” section that I add is overwritten every time.

As far as I can see there isn’t a place to add keys and values to the storage configuration anywhere in the WebUI. As the WebUI seems to mostly use the duplicacy binary for all tasks, I think it’d just be the configuration interface that is necessary to support the custom download URL.

3 Likes

Thank you for your contribution and sorry for not responding earlier. The changes look good but I haven’t had a chance to test it. My only reservation is this URL should be placed in the storage URL instead. For example, maybe we need a new storage prefix such as b2-alt:// or b2-custom://, so the URL will be like b2-alt://foo.example.com/bucket/path.

1 Like

Ah, I see. Would it be enough to parse the URL with a modified regex?
Right now it’s matching:
^([\w-]+)://([\w\-@\.]+@)?([^/]+)(/(.+))?

b2 looks at 3 and 5 for the bucket and path respectively. The current pattern would still work if the URL was specified as b2://custom.url@bucket/path
Alternatively, a specific pattern for b2-custom:
^b2-custom://([^/]+)/([^/]+)(/(.+))?
That would put the URL in group 1, the bucket in 2, and the optional path in 4.
If that looks good I can make the changes and push an update to the PR.

If I’m looking at this correctly, that would mean the WebUI wouldn’t need to be modified to support this. Even better :slight_smile: Well, I suppose an interface would be needed to support configuring the new storage type, but this could also be configured manually by editing the json file.

1 Like

You don’t need a new regex; just use the general one (group 1 is b2-custom, group 3 is the URL, group 5 is the bucket and the path.

Right, for the current web version you can edit the storage url the json file. Once this feature gets into a CLI release I’ll update the web version to support it.

2 Likes

Ah, I didn’t think of that. I just pushed an update that does use a new regex. If you’d prefer, I can switch back to the default, though that would then require splitting group 5. Let me know your preference.

1 Like

That is ok. We can always make changes later. I’ll run a test and then merge the pull request.

1 Like

Just to put the link to the PR:

2 Likes

Just wanted to post an update on my own progress. I finally got around to trying my branch with the web UI. I replaced the command line binary and updated the storage URLs in duplicacy.json to use the b2-custom://b2.example.com/bucket format. I ran my scheduled tasks and restored around 200 MB of data. No data was charged against my B2 account and I could see the spike of data in the CloudFlare interface.

@gchen let me know if I can provide any assistance in your testing or if you want any changes to the PR.

1 Like