digint / btrbk

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

Subvolume recognized as //root on Fedora #443

Closed lzap closed 2 years ago

lzap commented 2 years ago

Hey, I am on Fedora Rawhide with the latest btrbk-0.31.3-1.fc36.noarch and here is my config:

transaction_log            /mnt/backup/btrbk.log
stream_buffer              512m

snapshot_preserve_min      2d
target_preserve_min        6m
archive_preserve_min       2y
snapshot_create ondemand
snapshot_dir btrbk

volume /
  subvolume root
  target /mnt/backup/root

I have a standard Fedora setup:

# btrfs su li /
ID 256 gen 1267386 top level 5 path root
ID 259 gen 1216410 top level 256 path var/lib/portables
ID 264 gen 1216410 top level 256 path var/lib/machines

But btrbk seems to attempt to call btrfs subvolume snapshot -r //root /btrbk/root.20220125 instead of btrfs subvolume snapshot -r root /btrbk/root.20220125 is this a bug?

# btrbk -v run
btrbk command line client, version 0.31.3  (Tue Jan 25 08:11:05 2022)
Using configuration: /etc/btrbk/btrbk.conf
Using transaction log: /mnt/backup/btrbk.log
Creating subvolume snapshot for: /root
[snapshot] source: /root
[snapshot] target: /btrbk/root.20220125
ERROR: Failed to create snapshot: /root -> /btrbk/root.20220125
ERROR: ... Command execution failed (exitcode=1)
ERROR: ... sh: btrfs subvolume snapshot -r //root /btrbk/root.20220125
ERROR: ... Not a Btrfs subvolume: Invalid argument
WARNING: Skipping subvolume section: Failed to create snapshot: /root -> /btrbk/root.20220125
Completed within: 0s  (Tue Jan 25 08:11:05 2022)
--------------------------------------------------------------------------------
Backup Summary (btrbk command line client, version 0.31.3)

    Date:   Tue Jan 25 08:11:05 2022
    Config: /etc/btrbk/btrbk.conf

Legend:
    ===  up-to-date subvolume (source snapshot)
    +++  created subvolume (source snapshot)
    ---  deleted subvolume
    ***  received subvolume (non-incremental)
    >>>  received subvolume (incremental)
--------------------------------------------------------------------------------
/root
!!! Aborted: Failed to create snapshot: /root -> /btrbk/root.20220125

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

Tried also with master, similar result:

# ./btrbk -v run
btrbk command line client, version 0.32.0-dev  (Tue Jan 25 08:17:45 2022)
Using configuration: /etc/btrbk/btrbk.conf
Using transaction log: /mnt/backup/btrbk.log
Creating subvolume snapshot for: /root
[snapshot] source: /root
[snapshot] target: /btrbk/root.20220125
ERROR: Failed to create snapshot: /root -> /btrbk/root.20220125
ERROR: ... Command execution failed (exitcode=1)
ERROR: ... sh: btrfs subvolume snapshot -r '/root' '/btrbk/root.20220125'
ERROR: ... Not a Btrfs subvolume: Invalid argument
WARNING: Skipping subvolume section: Failed to create snapshot: /root -> /btrbk/root.20220125
Completed within: 0s  (Tue Jan 25 08:17:45 2022)
--------------------------------------------------------------------------------
Backup Summary (btrbk command line client, version 0.32.0-dev)

    Date:   Tue Jan 25 08:17:45 2022
    Config: /etc/btrbk/btrbk.conf

Legend:
    ===  up-to-date subvolume (source snapshot)
    +++  created subvolume (source snapshot)
    ---  deleted subvolume
    ***  received subvolume (non-incremental)
    >>>  received subvolume (incremental)
--------------------------------------------------------------------------------
/root
!!! Aborted: Failed to create snapshot: /root -> /btrbk/root.20220125

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

Oh I have to use .! None of the examples in the README shows that yet this is the setup that Fedora installer creates:

snapshot_preserve_min      2d
target_preserve_min        6m
archive_preserve_min       2y
snapshot_create ondemand
snapshot_dir btrbk

volume /
  subvolume .
  target /mnt/backup/root

The man page says this is not recommended, why is that? Isn't this the only way to backup my root volume? Thanks.

digint commented 2 years ago

using 0.32.0, you should be able to have it simpler by omitting the (now optional) volume:

snapshot_preserve_min      2d
target_preserve_min        6m
archive_preserve_min       2y
snapshot_create ondemand

subvolume /
  snapshot_dir /btrbk
  target /mnt/backup/root

I don't recommend it, as it is pretty counter-intuitive to get the snapshots /btrbk inside the snapshotted subvolume /. Another reason is that your config depends on the mount options, and not on the subvolume layout starting at the root node (subvolid=5).