Safe to change B2 lifecycle settings?

Apologies if this is more of a question about B2. The default lifecycle setting on buckets there is “Keep all versions of the file” - I noticed after a while that “locks” and the files within it have asterisks next to them, indicating, it seems, multiple revisions of the same filename. Maybe this is the case with other files in the bucket, but I haven’t looked through them all.

As far as restic goes, would it be safe to change the lifecycle setting to “Keep only the last version of the file”?

1 Like

Thanks for asking. I think it is reasonable (and safe) to set this to “Keep only last version”. The background is that restic will by default never write the same file twice: Due to the way the repo is structured combined with the encryption the file name will always be different. The only exception is the file config, but that will also not change in the current version of restic.

This may be something we could add to the documentation. I haven’t found a way to set this when creating a new bucket (at least not with the current library we’re using, https://github.com/kurin/blazer).

I’m wondering though: Could you please have a look if there are indeed multiple versions of files below locks/? It shouldn’t be the case, because restic will remove files and create new lock files with different names, so that’s a bit odd.

Oh, you know, I totally forgot, I only use the B2 backend if I’m restoring; I use rclone to sync my backups to B2, since I backup locally to a hard drive then keep a remote copy of the backup off-site. This is the lock folder:

Maybe this simply means the lock file was deleted? I’m gonna change the lifecycle settings so it only keeps the last version of the file. I figure it’ll be fine. Thanks for your response!

That’s very likely the explanation: Maybe rclone writes files multiple times. And the hidden files are probably the deleted ones.

I may suggest to add a note about this into the doc: https://restic.readthedocs.io/en/stable/manual.html#backblaze-b2

Just to resurrect an old topic here… I found that if you are using

rclone sync

to send your backup to B2, you may want to also use the option:

--b2-hard-delete

Without this, even if you have “Keep only last version” set, when a file is deleted via the sync, a previous copy is kept. This may not be what you want.

If you have been doing this, check out:

https://rclone.org/b2/

for details.

I found this command was useful to clean up the old versions I had that I didn’t want:

rclone cleanup remote:bucket

1 Like

Thanks for mentioning this here!