#1499 PR merged: Avoid recreation of non-existing btrfs subvolumes (fix #1496)

Labels: enhancement, fixed / solved / done

OliverO2 opened issue at 2017-09-18 11:35:

This PR makes sure that a btrfs subvolume actually exists before trying to recreate it.

See #1496.

jsmeix commented at 2017-09-18 12:10:

@OliverO2
from plain looking at the code everything looks perfect!

I only wonder about the reason behind
why you added a new lib/btrfs-functions.sh script
and did not add your btrfs_subvolume_exists function
to the existing lib/filesystems-functions.sh script?

OliverO2 commented at 2017-09-18 12:19:

@jsmeix

Yes, I had considered filesystems-functions.sh but somehow decided against it. I agree that the content of btrfs-functions.sh could just go there. Would be simpler and more logical.

jsmeix commented at 2017-09-18 12:56:

If there are no objections I will merge it soon...

OliverO2 commented at 2017-09-18 14:00:

@jsmeix
While we're dealing with btrfs code, would you mind stripping the #btrfssnapshotsubvol comments from disklayout.conf?

Over here, disklayout.conf contains 268 lines, 213 of them (86%) are #btrfssnapshotsubvol comments. That makes it difficult to review and edit the file, especially if done via a console with limited screen real estate.

What about just putting just a comment about the number of snapshot volumes encountered in disklayout.conf and put the snapshot paths in the log file only?

jsmeix commented at 2017-09-19 08:20:

@OliverO2
for SUSE I have the btrfs snapshot subvolumes intentionally
listed in disklayout.conf but disabled from recreation.
At SUSE we can boot from a btrfs snapshot subvolume
when it was made by the SUSE tool 'snapper' - i.e. each
snapper btrfs snapshot subvolume could be used as
the subvolume that gets mounted at the '/' mountpoint.
Therefore I would like to have them listed in disklayout.conf.

In your case according to your valuable explanation in
https://github.com/rear/rear/issues/1496#issuecomment-329824117
"We snapshot each volume every 5 minutes"
you get tons of btrfs snapshot subvolumes which fill up
the disklayout.conf file with mostly useless information.

I suggest to provide another config variable so that the
user can specify if he wants to have btrfs snapshot subvolumes
listed in disklayout.conf
or
your existing support for EXCLUDE_RECREATE for btrfs
could be somehow enhanced to be also used to get btrfs
snapshot subvolumes completely ignored
e.g. via something like

EXCLUDE_RECREATE=( "${EXCLUDE_RECREATE[@]}" "btrfssnapshotsubvol:all" )

where a special qualifier like 'all' could mean that all btrfs
snapshot subvolumes get completely ignored
or
whatever else you like.

I only like that by default btrfs snapshot subvolumes
are still listed (but disabled) in disklayout.conf.

jsmeix commented at 2017-09-19 08:50:

I have tested that a ReaR recovery still works
with the SUSE SLES12-SP2 default btrfs structure.


[Export of Github issue for rear/rear.]