Backblaze B2 restore versions

I've successfully been using rclone with B2 Backblaze for more than a year now. I've never had to use the backed up files. Until now.

For most files I've disabled "versions". So every sync (that has file change) will overwrite the existing backed up file. All good.

But for some files I've been using B2's versions feature because I did want to keep old versions of a file.

In the B2 UI every such versioned file is created as a directory with the same name and then the latest version of the file under it.

/myfile.txt/myfile.txt

It turns out this is also how the api "presents" the files. So when I copy from B2 all files with versions turned on turns out like that. I had expected that the structure would be flattened to actually match the structure being synced.

rclone copy remote:bucket/* ./

Is there any way to flatten this automatically using rclone? If now how has other dealt with this?

Currently no, you are waiting on this issue to get implemented:

1 Like

After reading the issue I can see how that could solve the issue, but to me this seems to be moving an implementation detail in into user space.

My case is like this:

create myfile.txt

# local
myfile.txt
# remote
myfile.txt

then I edit the file

# local
myfile.txt
# remote
myfile.txt/myfile.txt

So really to me (as a user) there is really just the file and no directories.

Flatten as described by the issue owner seems be a generic flattening solution where the user wants to only get the files without preserving however many levels of directories (customizable or not). Whereas in my case I don't want to flatten files unless they are files in directories that were created by the version feature.

This is an implementation detail at B2 that they chose to represent versions this way.

I don't think --flatten is a fit for this.

E.g.

# local
myfile.txt
dir/myotherfile.txt
# remote
myfile.txt/myfile.txt
dir/myotherfile.text

In this case I don't want:

# local
myfile.txt
myotherfile.txt

To me --flatten signals a desired behavior that is different what my case. IMO the rclone copy or rclone sync should deal (if possible) with this transparently.

Did you try the --b2-versions flag? That is rclone's solution to this problem.

https://rclone.org/b2/#versions

Isn't that only to get old versions of a file?

Old versions of files, where available, are visible using the --b2-versions flag.

It gets current versions too - they just don't have the date in them.

How do you disable versions in B2? I can't figure it out.

You can disable rclone making versions by using the hard_delete config parameter or use --b2-hard-delete.

You can set this on a bucket too under the lifecycle settings in the web interface