Btrbk: Failed to fetch subvolume detail for snapshot_dir

Hello

I’m a new btrfs and btrbk user.
I’m trying to backup my laptop SSD to external USB HDD with btrbk.
Both internal and external drives are btrfs.
But unfortunately I unable to pass even the dry ran stage.
I’m keep getting the following error:

>sudo btrbk -l debug -c /home/nc/btrbk/btrbk-msi-laptop-2.conf -v -n run
btrbk command line client, version 0.32.6  (Sat Dec 23 17:54:29 2023)
Using configuration: /home/nc/btrbk/btrbk-msi-laptop-2.conf
WARNING: Skipping subvolume "/mnt/btr_pool/@": Failed to fetch subvolume detail for snapshot_dir
WARNING: ... Command execution failed (exitcode=1)
WARNING: ... sh: readlink -v -e '/mnt/btr_pool/btrbk_snapshots'
WARNING: ... readlink: /mnt/btr_pool/btrbk_snapshots: No such file or directory
Completed within: 0s  (Sat Dec 23 17:54:29 2023)
--------------------------------------------------------------------------------
Backup Summary (btrbk command line client, version 0.32.6)

    Date:   Sat Dec 23 17:54:29 2023
    Config: /home/nc/btrbk/btrbk-msi-laptop-2.conf
    Dryrun: YES

Legend:
    ===  up-to-date subvolume (source snapshot)
    +++  created subvolume (source snapshot)
    ---  deleted subvolume
    ***  received subvolume (non-incremental)
    >>>  received subvolume (incremental)
--------------------------------------------------------------------------------
/mnt/btr_pool/@
!!! Aborted: Failed to fetch subvolume detail for snapshot_dir

NOTE: Some errors occurred, which may result in missing backups!
Please check warning and error messages above.

NOTE: Dryrun was active, none of the operations above were actually executed!

Below some information about my system configuration:

>cat /etc/os-release 
NAME="openSUSE Tumbleweed-Slowroll"
# VERSION="20231219"
ID="opensuse-tumbleweed"
ID_LIKE="opensuse suse"
VERSION_ID="20231219"
PRETTY_NAME="openSUSE Tumbleweed-Slowroll"
ANSI_COLOR="0;32"
CPE_NAME="cpe:/o:opensuse:tumbleweed:20231219"
BUG_REPORT_URL="https://bugzilla.opensuse.org"
SUPPORT_URL="https://bugs.opensuse.org"
HOME_URL="https://www.opensuse.org"
DOCUMENTATION_URL="https://en.opensuse.org/openSUSE:Slowroll"
LOGO="distributor-logo-Tumbleweed"
> btrbk --version
btrbk command line client, version 0.32.6
at /home/nc/btrbk/btrbk-msi-laptop-2.conf 
snapshot_preserve_min   2d
snapshot_preserve       14d
target_preserve_min     no
target_preserve         20d 10w *m

target         /mnt/usb-backup/btrbk-msi-laptop

volume          /mnt/btr_pool/
 snapshot_dir    btrbk_snapshots
 subvolume      @
 #subvolume      @/home
 #subvolume     /@/var
 #subvolume     /@/usr/local
 #subvolume     /@/srv
 #subvolume     /@/root
 #subvolume     /@/opt
 #subvolume     /@/boot/grub2/x86_64-efi
 #subvolume     /@/boot/grub2/i386-pc
> cat /etc/fstab 
UUID=b16700d9-c4bb-427f-b7e0-e9f03e1aac03  /                       btrfs  defaults                      0  0
UUID=b16700d9-c4bb-427f-b7e0-e9f03e1aac03  /var                    btrfs  subvol=/@/var                 0  0
UUID=b16700d9-c4bb-427f-b7e0-e9f03e1aac03  /usr/local              btrfs  subvol=/@/usr/local           0  0
UUID=b16700d9-c4bb-427f-b7e0-e9f03e1aac03  /srv                    btrfs  subvol=/@/srv                 0  0
UUID=b16700d9-c4bb-427f-b7e0-e9f03e1aac03  /root                   btrfs  subvol=/@/root                0  0
UUID=b16700d9-c4bb-427f-b7e0-e9f03e1aac03  /opt                    btrfs  subvol=/@/opt                 0  0
UUID=b16700d9-c4bb-427f-b7e0-e9f03e1aac03  /home                   btrfs  subvol=/@/home                0  0
UUID=b16700d9-c4bb-427f-b7e0-e9f03e1aac03  /boot/grub2/x86_64-efi  btrfs  subvol=/@/boot/grub2/x86_64-efi  0  0
UUID=b16700d9-c4bb-427f-b7e0-e9f03e1aac03  /boot/grub2/i386-pc     btrfs  subvol=/@/boot/grub2/i386-pc  0  0
UUID=8159fe0a-742d-4fbd-becf-fb31cd93a64f  swap                    swap   defaults                      0  0
UUID=b16700d9-c4bb-427f-b7e0-e9f03e1aac03  /.snapshots             btrfs  subvol=/@/.snapshots          0  0

/dev/sda2  /mnt/btr_pool  btrfs  subvolid=5,noatime  0 0
> sudo btrfs subvolume list /
ID 256 gen 30 top level 5 path @
ID 257 gen 2089 top level 256 path @/var
ID 258 gen 1389 top level 256 path @/usr/local
ID 259 gen 1389 top level 256 path @/srv
ID 260 gen 1694 top level 256 path @/root
ID 261 gen 1390 top level 256 path @/opt
ID 262 gen 1997 top level 256 path @/home
ID 263 gen 25 top level 256 path @/boot/grub2/x86_64-efi
ID 264 gen 1213 top level 256 path @/boot/grub2/i386-pc
ID 265 gen 2027 top level 256 path @/.snapshots
ID 266 gen 2082 top level 265 path @/.snapshots/1/snapshot
ID 267 gen 76 top level 265 path @/.snapshots/2/snapshot
ID 268 gen 128 top level 265 path @/.snapshots/3/snapshot
ID 269 gen 378 top level 265 path @/.snapshots/4/snapshot
...
> sudo btrfs subvolume list /mnt/btr_pool 
ID 256 gen 30 top level 5 path @
ID 257 gen 2092 top level 256 path @/var
ID 258 gen 1389 top level 256 path @/usr/local
ID 259 gen 1389 top level 256 path @/srv
ID 260 gen 1694 top level 256 path @/root
ID 261 gen 1390 top level 256 path @/opt
ID 262 gen 1997 top level 256 path @/home
ID 263 gen 25 top level 256 path @/boot/grub2/x86_64-efi
ID 264 gen 1213 top level 256 path @/boot/grub2/i386-pc
ID 265 gen 2027 top level 256 path @/.snapshots
ID 266 gen 2082 top level 265 path @/.snapshots/1/snapshot
ID 267 gen 76 top level 265 path @/.snapshots/2/snapshot
...

reflink: Failed to fetch subvolume detail for snapshot_dir · Issue #576 · digint/btrbk · GitHub

You may want to provide more information. On host 3400g btrbk is configured as follows:

Source snapshot mount:

3400g:~ # grep /Btrbk /etc/fstab 
UUID=e7ad401f-4f60-42ff-a07e-f54372bc1dbc  /Btrbk                  btrfs  noauto,subvolid=5             0  0
3400g:~ # 

Target snapshot mount:

3400g:~ # grep /HDD /etc/fstab 
UUID=077f8a3b-ca24-4853-890c-fe38d452e1b8  /HDD                    btrfs  noauto ,subvolid=5                 0  0
3400g:~ # 

Everything goes to subvolumes btrbk_snapshots (suggested default of btrbk). They were created manually.

For ease of administration more subvolumes were created manually. Putting everything in a single folder will create a mess. Subvolume /Btrbk/btrbk_snapshots/HDD refers to the built-in HDD, /HDD/btrbk_snapshots/3400g to the host 3400g.

Set up a simple configuration. A single subvolume will suffice for this discussion. Backup / (root):

3400g:~ # cat /etc/btrbk/btrbk.conf
target                     /HDD/btrbk_snapshots/3400g
subvolume                  /
snapshot_dir               /Btrbk/btrbk_snapshots/HDD
3400g:~ # btrbk list config
SOURCE_SUBVOLUME  SNAPSHOT_PATH                  SNAPSHOT_NAME  TARGET_PATH
/                 /Btrbk/btrbk_snapshots/HDD     ROOT           /HDD/btrbk_snapshots/3400g
3400g:~ # 

btrbk at work:

3400g:~ # journalctl -b -u btrbk
Dec 24 07:31:38 3400g systemd[1]: Starting btrbk backup...
Dec 24 07:35:10 3400g btrbk[5882]: --------------------------------------------------------------------------------
Dec 24 07:35:10 3400g btrbk[5882]: Backup Summary (btrbk command line client, version 0.32.6)
Dec 24 07:35:10 3400g btrbk[5882]:     Date:   Sun Dec 24 07:31:48 2023
Dec 24 07:35:10 3400g btrbk[5882]:     Config: /etc/btrbk/btrbk.conf
Dec 24 07:35:10 3400g btrbk[5882]: Legend:
Dec 24 07:35:10 3400g btrbk[5882]:     ===  up-to-date subvolume (source snapshot)
Dec 24 07:35:10 3400g btrbk[5882]:     +++  created subvolume (source snapshot)
Dec 24 07:35:10 3400g btrbk[5882]:     ---  deleted subvolume
Dec 24 07:35:10 3400g btrbk[5882]:     ***  received subvolume (non-incremental)
Dec 24 07:35:10 3400g btrbk[5882]:     >>>  received subvolume (incremental)
Dec 24 07:35:10 3400g btrbk[5882]: --------------------------------------------------------------------------------
Dec 24 07:35:10 3400g btrbk[5882]: /
Dec 24 07:35:10 3400g btrbk[5882]: +++ /Btrbk/btrbk_snapshots/HDD/ROOT.20231224T0731
Dec 24 07:35:10 3400g btrbk[5882]: >>> /HDD/btrbk_snapshots/3400g/ROOT.20231224T0731
Dec 24 07:35:10 3400g btrbk[5882]: /home
Dec 24 07:35:10 3400g btrbk[5882]: +++ /Btrbk/btrbk_snapshots/HDD/home.20231224T0731
Dec 24 07:35:10 3400g btrbk[5882]: >>> /HDD/btrbk_snapshots/3400g/home.20231224T0731
Dec 24 07:35:10 3400g btrbk[5882]: /home-SSD
Dec 24 07:35:10 3400g btrbk[5882]: +++ /home-SSD/btrbk_snapshots/HDD/home-SSD.20231224T0731
Dec 24 07:35:10 3400g btrbk[5882]: >>> /HDD/btrbk_snapshots/3400g/home-SSD.20231224T0731
Dec 24 07:35:10 3400g disable-backup-disk[7656]: TARGET SOURCE    FSTYPE OPTIONS
Dec 24 07:35:10 3400g disable-backup-disk[7656]: /HDD   /dev/sdc1 btrfs  rw,nosuid,nodev,noexec,relatime,nospace_cache,subvolid=5,subvol=/
Dec 24 07:35:22 3400g systemd[1]: btrbk.service: Deactivated successfully.
Dec 24 07:35:22 3400g systemd[1]: Finished btrbk backup.
Dec 24 07:35:22 3400g systemd[1]: btrbk.service: Consumed 18.851s CPU time.
3400g:~ # 

Hope that helps.

Hi

Thank you for publishing your btrbg setup.
But unfortunately it didn’t helped me to understand what exactly wrong with mine…

It’s btrbk.

!!! Aborted: Failed to fetch subvolume detail for snapshot_dir

From “Example” btrbk - README

“Btrbk does not create subdirs by default, the snapshot directory must first be created manually”

I already know that and dispute the following message during dry-run the /mnt/btr_pool/btrbk_snapshots exist:

WARNING: ... sh: readlink -v -e '/mnt/btr_pool/btrbk_snapshots'
WARNING: ... readlink: /mnt/btr_pool/btrbk_snapshots: No such file or directory

Your configuration is puzzling. Show the following including the command line and the full unmodified output of the command:

3400g:~ # btrbk list config 
SOURCE_SUBVOLUME  SNAPSHOT_PATH                  SNAPSHOT_NAME  TARGET_PATH
/                 /Btrbk/btrbk_snapshots/HDD     ROOT           /HDD/btrbk_snapshots/3400g
/home             /Btrbk/btrbk_snapshots/HDD     home           /HDD/btrbk_snapshots/3400g
/home-SSD         /home-SSD/btrbk_snapshots/HDD  home-SSD       /HDD/btrbk_snapshots/3400g
3400g:~ # 
> btrbk list config
SOURCE_SUBVOLUME  SNAPSHOT_PATH                  SNAPSHOT_NAME  TARGET_PATH
/mnt/btr_pool/@   /mnt/btr_pool/btrbk_snapshots  @              /mnt/usb-backup/btrbk-msi-laptop
  1. Subvolume @ doesn’t contain any data as shown by the following:
3400g:~ # btrfs subvolume snapshot /Btrbk/@ snapshot
Create a snapshot of '/Btrbk/@' in './snapshot'
3400g:~ # find snapshot/
snapshot/
snapshot/var
snapshot/usr
snapshot/usr/local
snapshot/tmp
snapshot/srv
snapshot/root
snapshot/opt
snapshot/boot
snapshot/boot/grub2
snapshot/boot/grub2/x86_64-efi
snapshot/boot/grub2/i386-pc
snapshot/etc
snapshot/etc/snapper
snapshot/etc/snapper/configs
snapshot/etc/snapper/configs/root
snapshot/.snapshots
snapshot/home
3400g:~ # 
  1. Presumably you want to backup subvolumes containing data such as /@/.snapshots/2695/snapshot (mounted at /) or /Btrbk/@/var(mouted at /var).

  2. You may want to mount the source volume with subvolid=5 or subvol=/:

3400g:/Btrbk # grep /Btrbk /etc/fstab 
UUID=e7ad401f-4f60-42ff-a07e-f54372bc1dbc  /Btrbk                  btrfs  noauto,subvolid=5             0  0
3400g:/Btrbk # 
  1. Make sure the source subvolume exists, e.g. by running:
3400g:/Btrbk # btrfs subvolume show /home
@/home
        Name:                   home
        UUID:                   ded55a91-c261-d04c-ab9e-96ac2ac9ea5f
        Parent UUID:            -
        Received UUID:          -
        Creation time:          2021-12-24 21:38:11 +0100
        Subvolume ID:           2131
        Generation:             572757
        Gen at creation:        247383
        Parent ID:              256
        Top level ID:           256
        Flags:                  -
        Send transid:           0
        Send time:              2021-12-24 21:38:11 +0100
        Receive transid:        0
        Receive time:           -
        Snapshot(s):
                                btrbk_snapshots/Crucial/home.20231030T1429
                                btrbk_snapshots/Crucial/home.20231030T1709
...
        Quota group:            n/a
3400g:/Btrbk #