digint / btrbk

Tool for creating snapshots and remote backups of btrfs subvolumes
https://digint.ch/btrbk/
GNU General Public License v3.0
1.64k stars 120 forks source link

btrbk usage fails on Asustor NAS #469

Closed norbusan closed 2 years ago

norbusan commented 2 years ago

btrbk version 0.32.1 Arch Linux

Running btrbk usage fails:

sudo btrbk usage

ERROR: process died unexpectedly (btrbk v0.32.1)
Please contact the author: ......

Stack Trace:
----------------------------------------
Use of uninitialized value $detail{"data_ratio"} in pattern match (m//) at /usr/bin/btrbk line 1095.
 at /usr/bin/btrbk line 389.
        main::__ANON__("Use of uninitialized value \$detail{\"data_ratio\"} in pattern m"...) called at /usr/bin/btrbk line 1095
        main::btrfs_filesystem_usage(HASH(0x559bdeb83ab8)) called at /usr/bin/btrbk line 6440
        main::__ANON__(HASH(0x559bdeb4fac8), "target") called at /usr/bin/btrbk line 6452

This happens when parsing the output of the remote system (Asustor NAS). The output of the btrfs filesystem usage /volume1 call is:

total 7996865249280
allocated 5367660544000
unallocated 2629204705280
missing 0
used 5359242727424
free 2630672003072

Data 5306046926848
Metadata 26597343232
System 557056
Unallocated:
   /dev/md1        2.39TiB

The btrfs that is on the remote system is from btrfs-progs v5.6.

If necessary, I can try to update the binary on the remote side.

Thanks

Norbert

digint commented 2 years ago

Seems like Asustor also patches btrfs-progs, *sigh*. Synology is also doing this in some places, guess they both steal from each other...

I double-checked "vanilla" btrfs-progs-5.6:

# ./btrfs --version
btrfs-progs v5.6
# ./btrfs filesystem usage /
Overall:
    Device size:         255.98GiB
    Device allocated:        231.01GiB
    Device unallocated:       24.97GiB
    Device missing:          0.00B
    Used:            226.13GiB
    Free (estimated):         27.72GiB  (min: 27.72GiB)
    Data ratio:               1.00
    Metadata ratio:           1.00
    Global reserve:      455.02MiB  (used: 0.00B)

Data,single: Size:225.00GiB, Used:222.25GiB (98.78%)
   /dev/mapper/root  225.00GiB

Metadata,single: Size:6.01GiB, Used:3.87GiB (64.49%)
   /dev/mapper/root    6.01GiB

System,single: Size:4.00MiB, Used:48.00KiB (1.17%)
   /dev/mapper/root    4.00MiB

Unallocated:
   /dev/mapper/root   24.97GiB

Will try to make the code a bit more resilient later...

digint commented 2 years ago

fixed in: eadeb892328f6275088b4d1208bed256acf88a4d

The fix does not parse the output of the "Asustor NAS btrfs-progs", but rather fails with a more user-friendly message:

ERROR: Failed to parse filesystem usage detail (unsupported btrfs-progs) for: /mnt/btr_pool
digint commented 2 years ago

included in btrbk-0.32.2

norbusan commented 2 years ago

Thanks, confirmed that it doesn't crash but gives an error message now.