digint / btrbk

Tool for creating snapshots and remote backups of btrfs subvolumes
https://digint.ch/btrbk/
GNU General Public License v3.0
1.64k stars 120 forks source link

Question: Why is it recommended to mount `subvolid=5` when backing up `/`? #466

Open camoz opened 2 years ago

camoz commented 2 years ago

The README states:

Mounting subvolid=5 is recommended (mandatory for btrbk < v0.32.0) if you want to backup your root filesystem /.

I assume "root filesystem /" here refers to the OS root, not the top-level subvolume.

Why is it recommended to do that? I.e., why is it recommended against doing:

snapshot_dir /mnt/snapshots
subvolume /
ATLief commented 2 years ago

@camoz I'm not affiliated with the project (yet), but it might be to generate more human-readable snapshot "names" (the string in the snapshot filename). The filename of your sub-volume can (and probably will be) descriptive of the content, resulting in its snapshots having that property too. I would also imagine that btrbk doesn't have as easy access to the sub-volume name when all it's told is "/".

You may not be aware of btrfs's ability to mount sub-volumes as if they were the root of the filesystem, which makes using a sub-volume for the main content very easy to manage.

digint commented 2 years ago

It's less of a technical restriction (btrfs should be able to cope with that), here's some reasons that come into my mind:

I do not want to give an exhaustive explanation in this part of the README. But you are right, if I'm recommending something I should probably say why somewhere. Gladly taking suggestions, will think of it again later (and probably do some tests on how btrfs behaves exactly).

camoz commented 2 years ago

Ah, I think I have not correctly described what I mean...

I was talking about a btrfs layout where /mnt/snapshots is not a nested subvolume below /, like this:

subvolume                   mountpoint
----------------------------------------
id=5                        /mnt/btrfsvol
+-@snapshots                /mnt/snapshots
+-@                         /
+-@home                     /home

With a setup like this, is there still a (great) difference between using subvolid=5 and using the (non-nested) /mnt/snapshots for backing up the root subvolume? I assume no...

skug67 commented 2 years ago

UPDATE: Had installed via Debian (on bullseye) so was running an older version. Updated to 0.32 (using the bookworm repository) and was able torun using my subvolume/mount setup. Apologies for the uninformed post below and thanks for the great project.

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

If I understand the point @camoz is trying to make, then I agree with it. I similarly have a subvolume "@" that is mounted as my root filesystem and a separate subvolume "@snapshots" mounted elsewhere (in my case it's not /mnt/snapshots, but that hardly matters). It seems like it would be much more convenient to be able to invoke btrbk by setting those two locations as the subvolume and snapshot_dir parameters (respectively) in btrbk.conf rather than needing to separately mount subvolid=5 someplace.