#3243 Issue closed: rear checklayout: possibility to ignore certain logical volume?

Labels: support / question, fixed / solved / done

damm620 opened issue at 2024-06-11 09:18:

  • ReaR version ("/usr/sbin/rear -V"):
    2.7

We have a logic, that creates a so called dummy logical volume to make sure there is always a minumum amout of storage free in the os volume group to use with snapshots.
The creating and deleting of this special logical volume is noticed by the rear checklayout.
That is technically right because that is in fact a layout change, but we would like to ignore those changes.
This is because we have the following cronjob daily run on our systems:

/usr/sbin/rear checklayout
if [[ $? != 0 ]]; then
   TMPDIR=/tmp /usr/sbin/rear mkrescue
fi

As you can see, a rear mkrescue is triggered, when the checklayout checks a difference.
Is it possible to ignore the creation/deletion of one specific logical volume?
Maybe that the checklayout command is printing out the difference (is there a parameter to do so?), so that it could be evaluated by the cronjob and the decision weather it needs to run a rear mkrescure is done more whisely and not only done by the returncode?

jsmeix commented at 2024-06-14 07:30:

@damm620
I never tried out what you ask for
so the following is only what I assume:

In general all ReaR config options are
(more or less well) described in
usr/share/rear/conf/default.conf

According to what I found in default.conf
there is only EXCLUDE_VG but there is no EXCLUDE_LV
which you would need to only exclude a LV.

What may work (not yet tested by me) to exclude a LV
is using the more generic EXCLUDE_COMPONENTS array.
In this case you need to inspect your
var/lib/rear/layout/disklayout.conf
and your
var/lib/rear/layout/disktodo.conf
how your 'dummy' LV of your 'os' VG is stored,
for example in disklayout.conf it could be like

lvmvol /dev/os dummy ...

with a matching entry in disktodo.conf like

todo /dev/mapper/os-dummy lvmvol

so in this example

EXCLUDE_COMPONENTS+=( /dev/mapper/os-dummy )

in etc/rear/local.conf should result
that the 'dummy' LV gets excluded/disabled:
In disklayout.conf the entry gets commented out and
in disktodo.conf the entry gets marked as 'done'.

But this would result that your 'dummy' LV
may not get recreated during "rear recover"
which depends on how the LVM things are recreated:

When LVM things are recreated by using
the modern/default 'lvm vgcfgrestore' method,
then LVM things get recreated as stored in
var/lib/rear/layout/lvm/system.cfg
and there things are not excluded which are
specified via EXCLUDE_COMPONENTS.
So when LVM things get recreated via 'lvm vgcfgrestore'
your 'dummy' LV should get recreated during "rear recover"
regardless that you excluded it via EXCLUDE_COMPONENTS
(which is actually a bug in ReaR).

In contrast when LVM things get recreated by using
traditional/fallback 'vgcreate/lvcreate' commands,
then LVM things get recreated as stored in
var/lib/rear/layout/disklayout.conf
and therein your 'dummy' LV is commented out
so in this case your 'dummy' LV will
not be recreated during "rear recover".

damm620 commented at 2024-06-18 05:47:

thanks for your detailed answer. I will try this and give you feedback.

That the dummy lv will maybe not restored is not that munch of a problem :)

damm620 commented at 2024-06-18 08:06:

@jsmeix

It seems to be working pretty fine. Thank you very munch!

One last question:
After adding the EXCLUDE_COMPONENTS parameter do we need to run a mkrescue?
In my tests it seems to be that way.

jsmeix commented at 2024-06-18 09:54:

@damm620
in general when you change a ReaR config setting
you should run at least "rear mkrescue".

Additionally you should also think about
making a new backup, cf. the two parts about
"ensure your backup is consistent" in the section
"Relax-and-Recover versus backup and restore"
in
https://en.opensuse.org/SDB:Disaster_Recovery

In this specific case you needed "rear mkrescue"
to create a new var/lib/rear/layout/disklayout.conf
because "rear checklayout" also creates a new
temporary .../rear.XXXX/tmp/checklayout.conf
and compares that with the already existing
var/lib/rear/layout/disklayout.conf from "rear mkrescue"
so to get both same you need the excluded things in both,
cf. usr/share/rear/layout/compare/default/500_compare_layout.sh

damm620 commented at 2024-06-19 06:46:

@jsmeix

As I did not find it quickly in the code:
Are lvm snapshots excluded by default from the checklayout process?

jsmeix commented at 2024-06-19 07:33:

@damm620
I am not a sufficient LVM expert
to answer questions about "LVM snapshots" properly.

In general there is no special 'checklayout' process.
In particular there are no special exclusions for 'checklayout'.
What "rear checklayout" does is to create a new temporary
.../rear.XXXX/tmp/checklayout.conf
exactly the same as the normal
var/lib/rear/layout/disklayout.conf
is created by "rear mkrescue"
and then "rear checklayout" compares both files.

So the question
"Are lvm snapshots excluded by default from the checklayout process?"
should be - as far as I understand things - equivalent to
"Are lvm snapshots excluded by default?"

You could verify that by checking your normal
var/lib/rear/layout/disklayout.conf
that was created by "rear mkrescue"
whether or not LVM snapshots are excluded therein.

jsmeix commented at 2024-06-20 11:55:

According to the code in
usr/share/rear/layout/save/GNU/Linux/220_lvm_layout.sh

{
...
    lvm lvs --separator=':' --noheadings --units b --nosuffix -o $lvs_fields | sort -n -t ':' -k 4 | while read line ; do
...
        origin="$( echo "$line" | awk -F ':' '{ print $1 }' )"
        # Skip snapshots (useless) or caches (dont know how to handle that)
        if test "$origin" ; then
            echo "# Skipped snapshot or cache information '$line'"
            continue
        fi
...
} 1>>$DISKLAYOUT_FILE

for ReaR 2.7 online at
https://github.com/rear/rear/blob/rear-2.7/usr/share/rear/layout/save/GNU/Linux/220_lvm_layout.sh#L266
LVM snapshots should get hardcoded excluded
from var/lib/rear/layout/disklayout.conf
and you should get comments of the form

# Skipped snapshot or cache information '...'

in your var/lib/rear/layout/disklayout.conf
that show what LVM snapshots are excluded.

damm620 commented at 2024-06-20 12:01:

great! thanks :)


[Export of Github issue for rear/rear.]