Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
jadupl2 opened this issue Apr 21, 2021 · 9 comments
Closed

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

jadupl2 opened this issue Apr 21, 2021 · 9 comments

Comments

@jadupl2
Copy link

jadupl2 commented Apr 21, 2021

  • 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
Copy link
Member

gdha commented Apr 22, 2021

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

@jadupl2
Copy link
Author

jadupl2 commented Apr 22, 2021 via email

@jsmeix
Copy link
Member

jsmeix commented Apr 22, 2021

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

@jsmeix jsmeix closed this as completed Apr 22, 2021
@jsmeix jsmeix changed the title Fedora 33 - /home not included in backup if btrfs filesystem /home not included in NETFS backup when it is a btrfs subvolume Apr 22, 2021
@gdha
Copy link
Member

gdha commented Apr 22, 2021

@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
Copy link
Author

jadupl2 commented Apr 22, 2021 via email

@jsmeix
Copy link
Member

jsmeix commented Apr 22, 2021

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
Copy link
Member

jsmeix commented Apr 22, 2021

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
Copy link
Member

jsmeix commented Apr 22, 2021

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
Copy link
Member

jsmeix commented Apr 22, 2021

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=

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants