#2604 Issue closed: /home not included in NETFS backup when it is a btrfs subvolume

Labels: support / question, fixed / solved / done

jadupl2 opened issue at 2021-04-21 15:19:

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

  • jacques@yoda:~ $ rear -V
    Relax-and-Recover 2.6 / 2020-06-17

  • OS version ("cat /etc/os-release" or "lsb_release -a" or "cat /etc/rear/os.conf"):

jacques@yoda:~ $ lsb_release -a
LSB Version:    :core-4.1-amd64:core-4.1-noarch
Distributor ID: Fedora
Description:    Fedora release 33 (Thirty Three)
Release:    33
Codename:   ThirtyThree
jacques@yoda:~ $
  • ReaR configuration files ("cat /etc/rear/site.conf" and/or "cat /etc/rear/local.conf"):
# File created by sadm_postinstall.sh v4.31 on Mon Nov  9 11:56:31 AM EST 2020
#
# Default PostInstall Rear Client Configuration
# ----------------------------------------------------------------------
#
# Create a bootable ISO9660 image on disk as rear-yoda.maison.ca.iso
OUTPUT=ISO
#
#Internal backup method which can be used to create a simple backup (tar archive).
BACKUP=NETFS
#
# Directory within mount point where iso and tgz will be stored
NETFS_PREFIX="yoda"
#
# To backup to NFS disk, use BACKUP_URL=nfs://nfs-server-name/share/path
BACKUP_URL="nfs://batnas.maison.ca/volume1/backup_rear"
#
# disable SELinux while the backup is running
BACKUP_SELINUX_DISABLE=1
#
# Prefix name for ISO images without the .iso suffix (rear_HOSTNAME.iso)
ISO_PREFIX="rear_yoda"
#
# Name of Backup (tar.gz) File
BACKUP_PROG_ARCHIVE="rear_yoda"
#
#
# Exclude Volume Group (and filesystem they include)
# Don't forget to comment filesystem on excludevg in /etc/fstab prior to 1st reboot
EXCLUDE_VG=(datavg)
EXCLUDE_MOUNTPOINTS=(/lvol1)
  • Hardware (PC or PowerNV BareMetal or ARM) or virtual machine (KVM guest or PoverVM LPAR):
    Dell Laptop D630

  • System architecture (x86 compatible or PPC64/PPC64LE or what exact ARM device):

root@yoda:/etc/rear  # uname -a
Linux yoda.maison.ca 5.11.11-200.fc33.x86_64 #1 SMP Tue Mar 30 16:53:32 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
root@yoda:/etc/rear  #
  • Firmware (BIOS or UEFI or Open Firmware) and bootloader (GRUB or ELILO or Petitboot):
    BIOS
  • Storage (local disk or SSD) and/or SAN (FC or iSCSI or FCoE) and/or multipath (DM or NVMe):
    SSD
  • Storage layout ("lsblk -ipo NAME,KNAME,PKNAME,TRAN,TYPE,FSTYPE,SIZE,MOUNTPOINT" or "lsblk" as makeshift):
root@yoda:/etc/rear  # lsblk -ip
NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
/dev/sda      8:0    0 111.8G  0 disk 
|-/dev/sda1   8:1    0     1G  0 part /boot
`-/dev/sda2   8:2    0 110.8G  0 part /home
/dev/sr0     11:0    1  1024M  0 rom  
/dev/zram0  252:0    0   1.9G  0 disk [SWAP]
root@yoda:/etc/rear  #
  • Description of the issue (ideally so that others can reproduce it):
    Just do a rear backup , and check backup content /home not included

  • Workaround, if any:
    Did not find one

rear_yoda.log.zip
rear-yoda.log.zip

  • Attachments, as applicable ("rear -D mkrescue/mkbackup/recover" debug log files):

gdha commented at 2021-04-22 08:22:

@jadupl2 Could you paste the /var/lib/rear/layout/disklayout.conf file please? And, the output of mount -v

jadupl2 commented at 2021-04-22 13:13:

Here there are .
Thank you in advance

$ cat /var/lib/rear/layout/disklayout.conf
# Disk layout dated 20210422000514 (YYYYmmddHHMMSS)
# NAME        KNAME      PKNAME   TRAN TYPE FSTYPE   SIZE MOUNTPOINT
# /dev/sda    /dev/sda            ata  disk        111.8G
# |-/dev/sda1 /dev/sda1  /dev/sda      part ext4       1G /boot
# `-/dev/sda2 /dev/sda2  /dev/sda      part btrfs  110.8G /home
# /dev/sr0    /dev/sr0            ata  rom          1024M
# /dev/zram0  /dev/zram0               disk          1.9G [SWAP]
# Disk /dev/sda
# Format: disk <devname> <size(bytes)> <partition label type>
disk /dev/sda 120034123776 msdos
# Partitions on /dev/sda
# Format: part <device> <partition size(bytes)> <partition start(bytes)>
<partition type|name> <flags> /dev/<partition>
part /dev/sda 1073741824 1048576 primary boot /dev/sda1
part /dev/sda 118958850048 1074790400 primary none /dev/sda2
# Filesystems (only ext2,ext3,ext4,vfat,xfs,reiserfs,btrfs are supported).
# Format: fs <device> <mountpoint> <fstype> [uuid=<uuid>] [label=<label>]
[<attributes>]
fs /dev/sda1 /boot ext4 uuid=9cbff2d8-d27e-4c02-997a-c91f948bb124
label=/boot blocksize=4096 reserved_blocks=4% max_mounts=-1
check_interval=0d bytes_per_inode=16384
default_mount_options=user_xattr,acl options=rw,relatime,seclabel
fs /dev/sda2 / btrfs uuid=f35c28b2-8afc-4ff2-9adc-f37fe0d0f6a8
label='fedora_localhost-live'
options=rw,relatime,ssd,space_cache,subvolid=257,subvol=/root
# Btrfs default subvolume for /dev/sda2 at /
# Format: btrfsdefaultsubvol <device> <mountpoint> <btrfs_subvolume_ID>
<btrfs_subvolume_path>
btrfsdefaultsubvol /dev/sda2 / 5 /
# Btrfs normal subvolumes for /dev/sda2 at /
# Format: btrfsnormalsubvol <device> <mountpoint> <btrfs_subvolume_ID>
<btrfs_subvolume_path>
btrfsnormalsubvol /dev/sda2 / 256 home
btrfsnormalsubvol /dev/sda2 / 257 root
btrfsnormalsubvol /dev/sda2 / 258 root/var/lib/machines
# All mounted btrfs subvolumes (including mounted btrfs default subvolumes
and mounted btrfs snapshot subvolumes).
# Determined by the findmnt command that shows the mounted
btrfs_subvolume_path.
# Format: btrfsmountedsubvol <device> <subvolume_mountpoint>
<mount_options> <btrfs_subvolume_path>
btrfsmountedsubvol /dev/sda2 /
rw,relatime,seclabel,ssd,space_cache,subvolid=257,subvol=/root root
btrfsmountedsubvol /dev/sda2 /home
rw,relatime,seclabel,ssd,space_cache,subvolid=256,subvol=/home home
# Mounted btrfs subvolumes that have the 'no copy on write' attribute set.
# Format: btrfsnocopyonwrite <btrfs_subvolume_path>
# Swap partitions or swap files
# Format: swap <filename> uuid=<uuid> label=<label>
swap /dev/zram0 uuid=e7d3bc7c-9a31-4a4f-b69d-fa0f752140e2 label=

$ mount -v
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime,seclabel)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
devtmpfs on /dev type devtmpfs
(rw,nosuid,noexec,seclabel,size=1985616k,nr_inodes=496404,mode=755,inode64)
securityfs on /sys/kernel/security type securityfs
(rw,nosuid,nodev,noexec,relatime)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev,seclabel,inode64)
devpts on /dev/pts type devpts
(rw,nosuid,noexec,relatime,seclabel,gid=5,mode=620,ptmxmode=000)
tmpfs on /run type tmpfs
(rw,nosuid,nodev,seclabel,size=801956k,nr_inodes=819200,mode=755,inode64)
cgroup2 on /sys/fs/cgroup type cgroup2
(rw,nosuid,nodev,noexec,relatime,seclabel,nsdelegate)
pstore on /sys/fs/pstore type pstore
(rw,nosuid,nodev,noexec,relatime,seclabel)
none on /sys/fs/bpf type bpf (rw,nosuid,nodev,noexec,relatime,mode=700)
none on /sys/kernel/tracing type tracefs (rw,relatime,seclabel)
/dev/sda2 on / type btrfs
(rw,relatime,seclabel,ssd,space_cache,subvolid=257,subvol=/root)
selinuxfs on /sys/fs/selinux type selinuxfs (rw,nosuid,noexec,relatime)
systemd-1 on /proc/sys/fs/binfmt_misc type autofs
(rw,relatime,fd=30,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=17017)
hugetlbfs on /dev/hugepages type hugetlbfs
(rw,relatime,seclabel,pagesize=2M)
mqueue on /dev/mqueue type mqueue (rw,nosuid,nodev,noexec,relatime,seclabel)
debugfs on /sys/kernel/debug type debugfs
(rw,nosuid,nodev,noexec,relatime,seclabel)
fusectl on /sys/fs/fuse/connections type fusectl
(rw,nosuid,nodev,noexec,relatime)
configfs on /sys/kernel/config type configfs
(rw,nosuid,nodev,noexec,relatime)
/dev/sda2 on /home type btrfs
(rw,relatime,seclabel,ssd,space_cache,subvolid=256,subvol=/home)
/dev/sda1 on /boot type ext4 (rw,relatime,seclabel)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw,relatime)
tmpfs on /run/user/42 type tmpfs
(rw,nosuid,nodev,relatime,seclabel,size=400976k,nr_inodes=100244,mode=700,uid=42,gid=42,inode64)
tmpfs on /run/user/1001 type tmpfs
(rw,nosuid,nodev,relatime,seclabel,size=400976k,nr_inodes=100244,mode=700,uid=1001,gid=1001,inode64)
binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc
(rw,nosuid,nodev,noexec,relatime)
tmpfs on /run/user/1000 type tmpfs
(rw,nosuid,nodev,relatime,seclabel,size=400976k,nr_inodes=100244,mode=700,uid=1000,gid=1000,inode64)

$ df
Filesystem     1K-blocks     Used Available Use% Mounted on
devtmpfs         1985616        0   1985616   0% /dev
tmpfs            2004884        0   2004884   0% /dev/shm
tmpfs             801956     1696    800260   1% /run
/dev/sda2      116170752 22706588  92788980  20% /
/dev/sda2      116170752 22706588  92788980  20% /home
/dev/sda1         999320   310504    620004  34% /boot
tmpfs             400976       80    400896   1% /run/user/42
tmpfs             400976       56    400920   1% /run/user/1001
tmpfs             400976       56    400920   1% /run/user/1000

jsmeix commented at 2021-04-22 13:37:

In general btrfs subvolumes behave like separated filesystems.

With BACKUP=NETFS ReaR calls tar with --one-file-system
cf. usr/share/rear/backup/NETFS/default/500_make_backup.sh
https://github.com/rear/rear/blob/master/usr/share/rear/backup/NETFS/default/500_make_backup.sh

So what behaves like separated filesystems must be explicitly
specified in the BACKUP_PROG_INCLUDE array.
For an example see
usr/share/rear/conf/examples/SLE12-SP2-btrfs-example.conf
in particular see the comments therein
https://github.com/rear/rear/blob/master/usr/share/rear/conf/examples/SLE12-SP2-btrfs-example.conf

gdha commented at 2021-04-22 13:40:

@jsmeix Thanks Johannes as I was up to write the same thing to have a look at the example conf file of SLE12-SP2-btrfs to get some inspiration. Can this be automated somehow??

jadupl2 commented at 2021-04-22 13:51:

Thank You very much
I will include /home in the BACKUP_PROG_INCLUDE array
A+

On Thu, Apr 22, 2021 at 9:37 AM Johannes Meixner ***@***.***>
wrote:

In general btrfs subvolumes behave like separated filesystems.

With BACKUP=NETFS ReaR calls tar with --one-file-system
cf. usr/share/rear/backup/NETFS/default/500_make_backup.sh

https://github.com/rear/rear/blob/master/usr/share/rear/backup/NETFS/default/500_make_backup.sh

So what behaves like separated filesystems must be explicitly
specified in the BACKUP_PROG_INCLUDE array.
For an example see
usr/share/rear/conf/examples/SLE12-SP2-btrfs-example.conf
in particular see the comments therein

https://github.com/rear/rear/blob/master/usr/share/rear/conf/examples/SLE12-SP2-btrfs-example.conf


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/rear/rear/issues/2604#issuecomment-824848943, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/ABQUGCPXSALSMCQUI53IM7DTKARCRANCNFSM43KSL63A
.

jsmeix commented at 2021-04-22 13:57:

I think it cannot be automated with reasonable effort to work reasonably well
at least not for SUSE's complicated default btrfs structure that I know about.

I have no good idea how to find out in a reasonable automated way
what btrfs subvolumes are of interest for the user to be in the backup.

At least one main problem are btrfs snapshot subvolumes, see
https://en.opensuse.org/SDB:Disaster_Recovery#btrfs

In general I won't implement automatisms for btrfs on my own
because I had already too much pain and trouble with btrfs stuff
so I would only work on btrfs things when I am forced, e.g. by
a SUSE customer who has a sufficient SUSE contract to get
btrfs enhancements for ReaR implemented by SUSE ;-)

But often I am just confused when I try to think about btrfs things
because I was hit by too many special cases with btrfs
so I may not see some obvious simple and straightforward way
that would "do the right thing" for most of the usual btrfs use cases.

jsmeix commented at 2021-04-22 14:08:

For normal cases (i.e. when no btrfs subvolumes are used) we have in
usr/share/rear/backup/NETFS/default/400_create_include_exclude_files.sh

# Implicitly also backup all local filesystems as defined in mountpoint_device
...
        while read mountpoint device junk ; do
            if ! IsInArray "$mountpoint" "${EXCLUDE_MOUNTPOINTS[@]}" ; then
                echo "$mountpoint"
            fi
        done <"$VAR_DIR/recovery/mountpoint_device" >> $TMP_DIR/backup-include.txt

and according to the df output of @jadupl2

Filesystem     1K-blocks     Used Available Use% Mounted on
...
/dev/sda2      116170752 22706588  92788980  20% /
/dev/sda2      116170752 22706588  92788980  20% /home

/home is mounted but the above code does somehow
(currently I don't see how the mountpoint_device stuff works)
not add /home to the backup-include.txt file.

jsmeix commented at 2021-04-22 14:14:

The mountpoint_device file is populated via
usr/share/rear/layout/save/default/340_generate_mountpoint_device.sh

while read fs device mountpoint junk ; do
    if IsInArray "$mountpoint" "${excluded_mountpoints[@]}" ; then
        continue
    fi
    echo "$mountpoint $device"
done < <(grep '^fs' $LAYOUT_FILE) > $VAR_DIR/recovery/mountpoint_device

so it only considers the fs entries in disklayout.conf

Perhaps also considering the btrfsmountedsubvol entries in disklayout.conf
might even point into the right direction for automated btrfs backup includes
except possibly tons of unexpected special cases for btrfs...

jsmeix commented at 2021-04-22 14:16:

Here for better readability the disklayout.conf of @jadupl2

# Disk layout dated 20210422000514 (YYYYmmddHHMMSS)
# NAME        KNAME      PKNAME   TRAN TYPE FSTYPE   SIZE MOUNTPOINT
# /dev/sda    /dev/sda            ata  disk        111.8G
# |-/dev/sda1 /dev/sda1  /dev/sda      part ext4       1G /boot
# `-/dev/sda2 /dev/sda2  /dev/sda      part btrfs  110.8G /home
# /dev/sr0    /dev/sr0            ata  rom          1024M
# /dev/zram0  /dev/zram0               disk          1.9G [SWAP]
# Disk /dev/sda
# Format: disk <devname> <size(bytes)> <partition label type>
disk /dev/sda 120034123776 msdos
# Partitions on /dev/sda
# Format: part <device> <partition size(bytes)> <partition start(bytes)> <partition type|name> <flags> /dev/<partition>
part /dev/sda 1073741824 1048576 primary boot /dev/sda1
part /dev/sda 118958850048 1074790400 primary none /dev/sda2
# Filesystems (only ext2,ext3,ext4,vfat,xfs,reiserfs,btrfs are supported).
# Format: fs <device> <mountpoint> <fstype> [uuid=<uuid>] [label=<label>] [<attributes>]
fs /dev/sda1 /boot ext4 uuid=9cbff2d8-d27e-4c02-997a-c91f948bb124 label=/boot blocksize=4096 reserved_blocks=4% max_mounts=-1 check_interval=0d bytes_per_inode=16384 default_mount_options=user_xattr,acl options=rw,relatime,seclabel
fs /dev/sda2 / btrfs uuid=f35c28b2-8afc-4ff2-9adc-f37fe0d0f6a8 label='fedora_localhost-live' options=rw,relatime,ssd,space_cache,subvolid=257,subvol=/root
# Btrfs default subvolume for /dev/sda2 at /
# Format: btrfsdefaultsubvol <device> <mountpoint> <btrfs_subvolume_ID> <btrfs_subvolume_path>
btrfsdefaultsubvol /dev/sda2 / 5 /
# Btrfs normal subvolumes for /dev/sda2 at /
# Format: btrfsnormalsubvol <device> <mountpoint> <btrfs_subvolume_ID> <btrfs_subvolume_path>
btrfsnormalsubvol /dev/sda2 / 256 home
btrfsnormalsubvol /dev/sda2 / 257 root
btrfsnormalsubvol /dev/sda2 / 258 root/var/lib/machines
# All mounted btrfs subvolumes (including mounted btrfs default subvolumes and mounted btrfs snapshot subvolumes).
# Determined by the findmnt command that shows the mounted btrfs_subvolume_path.
# Format: btrfsmountedsubvol <device> <subvolume_mountpoint> <mount_options> <btrfs_subvolume_path>
btrfsmountedsubvol /dev/sda2 / rw,relatime,seclabel,ssd,space_cache,subvolid=257,subvol=/root root
btrfsmountedsubvol /dev/sda2 /home rw,relatime,seclabel,ssd,space_cache,subvolid=256,subvol=/home home
# Mounted btrfs subvolumes that have the 'no copy on write' attribute set.
# Format: btrfsnocopyonwrite <btrfs_subvolume_path>
# Swap partitions or swap files
# Format: swap <filename> uuid=<uuid> label=<label>
swap /dev/zram0 uuid=e7d3bc7c-9a31-4a4f-b69d-fa0f752140e2 label=

[Export of Github issue for rear/rear.]