Restic and B2 With Cloudflare

As I keep exploring my options for an offsite backup with Restic, I remembered B2 can have free egress if you configure it with Cloudflare.

I’m still not 100% sure how this works, but in rclone you can configure the URL to use with Cloudflare. Does Restic support the Cloudflare integration with B2 for free egress?

I don’t believe restic has built-in support, but if rclone supports it then you can use rclone serve restic and point restic at the local rclone server instead.

1 Like

I also thought about doing this but never got to actually try it. Please share your experience if you do :slight_smile:

So I tried this myself now which turned out to be quite easy with rclone actually. Just add something like this to your rclone config:

type = b2
account = <youraccountid>
key = <youraccountkey>
download_url = https://b2-f000.<yourdomain>/

b2-f000.<yourdomain> is a CNAME to in Cloudflare configured for proxying through Cloudflare. Verify that this is indeed the correct destination for your bucket by clicking the info icon on any file in the B2 webinterface and checking the URL there.

Restic can now be used like this: restic -r rclone:b2-cf:<yourbucket> ...

However, there are at least two caveats here: Cloudflare requires you to delegate DNS for the whole domain to them, only adding a subdomain to your account is not supported for whatever reason. And it probably also violates their Terms (at least in the free version), so use at your own risk:

2.8 Limitation on Serving Non-HTML Content

The Service is offered primarily as a platform to cache and serve web pages and websites. Unless explicitly included as a part of a Paid Service purchased by you, you agree to use the Service solely for the purpose of serving web pages as viewed through a web browser or other application and the Hypertext Markup Language (HTML) protocol or other equivalent technology. Use of the Service for serving video (unless purchased separately as a Paid Service) or a disproportionate percentage of pictures, audio files, or other non-HTML content, is prohibited.

1 Like

@Julian, thanks. Yeah I was considering using restic with rclone the way you describe. I’m a huge rclone fan, but I always prefer if my tools have native support for the cloud services they use. Still when I think it’s time to backup to B2, I may just do this.

Regarding the Terms you linked to, I think it’s fine because I won’t be serving the content to be publicly accessible, but I will def keep that in mind as it can be murky waters when I want to restore.

Is there really any reason to use Cloudflare? Why not just use B2 directly? What advantage is Cloudflare providing?

You get free egress when configured with Cloudflare.

Here’s the article.

Ah, I see. Yeah, that is almost certainly abuse of their free service.

In the first sentence of the article, they state that it’s a partnership.

The partnership between Backblaze and Cloudflare enables storing content on Backblaze’s B2 storage service and automatically feeding it as needed into Cloudflare’s CDN (Content Delivery Network).

That indicates, to me at least, that it’s not an abuse. If Backblaze and Cloudflare are partnered, they’d almost certainly know about this article.

It is a partnership that is intended to drive business for both parties – if you use them together, you’re effectively getting a discount. This incentivizes you to use both services.

Except that Cloudflare isn’t actually making any money under their free plan. They’re losing money, which is why this kind of usage is against their terms of service (see @Julian’s post) . Cloudflare’s goal is to convert you to a paying customer, not give away services for free.

Yeah, I see that now. Should have read that more carefully.

I’m a bit surprised Backblaze recommends the free tier in that case. :man_shrugging:

It makes sense. The idea is that you host your website/content there. As your usage grows, you outgrow the free tier and switch to a paid Cloudflare plan. Backblaze benefits from the storage revenue, and Cloudflare might pay a small commission to Backblaze.