btrfs subvolumes under root not backed up #983

Closed
opened 2025-01-29 08:10:35 +00:00 by onestay · 6 comments

What I'm trying to do and why

Hey, first of all thanks a lot for borgmatic. It's an excellent tool!

I am encountering a bit of an issue however. My setup is as follows:
btrfs subvolume @ mounted at /
btrfs subvolume @home mounted at /home

$ btrfs subvolume list /
ID 257 gen 95169 top level 5 path @home
ID 260 gen 95169 top level 5 path @

Now I want to backup my whole system. Meaning I added

source_directories:
  - "/"

However this leads to the /home directory not being snapshotted and remaining empty.

ssh://repo:23/home/borg/work_laptop: Snapshotting Btrfs subvolumes
findmnt -t btrfs --json --list
btrfs subvolume list /
btrfs subvolume list /home
ssh://repo:23/home/borg/work_laptop: Creating Btrfs snapshot for / subvolume
btrfs subvolume snapshot -r / /.borgmatic-snapshot-99638
Create readonly snapshot of '/' in '/.borgmatic-snapshot-99638'

/.borgmatic-snapshot-99638/home/ is empty.

This also happens if I explicitly mention "/home" in the source_directories, as well as if I list all the directories under / I want to backup manually under source_directories.

I'll be happy to provide any more information you need.

Thank you for your time!

Steps to reproduce

No response

Actual behavior

No response

Expected behavior

No response

Other notes / implementation ideas

No response

borgmatic version

1.9.8

borgmatic installation method

pipx

Borg version

1.4.0

Python version

3.13.1

Database version (if applicable)

No response

Operating system and version

Fedora Linux 41 (KDE)

### What I'm trying to do and why Hey, first of all thanks a lot for borgmatic. It's an excellent tool! I am encountering a bit of an issue however. My setup is as follows: btrfs subvolume @ mounted at / btrfs subvolume @home mounted at /home ``` $ btrfs subvolume list / ID 257 gen 95169 top level 5 path @home ID 260 gen 95169 top level 5 path @ ``` Now I want to backup my whole system. Meaning I added ```yaml source_directories: - "/" ``` However this leads to the `/home` directory not being snapshotted and remaining empty. ``` ssh://repo:23/home/borg/work_laptop: Snapshotting Btrfs subvolumes findmnt -t btrfs --json --list btrfs subvolume list / btrfs subvolume list /home ssh://repo:23/home/borg/work_laptop: Creating Btrfs snapshot for / subvolume btrfs subvolume snapshot -r / /.borgmatic-snapshot-99638 Create readonly snapshot of '/' in '/.borgmatic-snapshot-99638' ``` `/.borgmatic-snapshot-99638/home/` is empty. This also happens if I explicitly mention "/home" in the source_directories, as well as if I list all the directories under `/` I want to backup manually under source_directories. I'll be happy to provide any more information you need. Thank you for your time! ### Steps to reproduce _No response_ ### Actual behavior _No response_ ### Expected behavior _No response_ ### Other notes / implementation ideas _No response_ ### borgmatic version 1.9.8 ### borgmatic installation method pipx ### Borg version 1.4.0 ### Python version 3.13.1 ### Database version (if applicable) _No response_ ### Operating system and version Fedora Linux 41 (KDE)
Owner

Thanks for filing this! Could I see the output of findmnt -t btrfs --list on your system? That's what borgmatic uses internally to probe for subvolume mount points. Based on the output above, I'm guessing it is finding /home correctly, but it'd be good to confirm.

I would actually expect /.borgmatic-snapshot-99638/home/ to be empty, because borgmatic doesn't do recursive snapshotting. Instead, I would expect it to do a separate snapshot of your /home subvolume mount point—if it's explicitly listed in your source_directories. So there's nothing in the output about Creating Btrfs snapshot for /home subvolume? And what happens if you omit / from source_directories but include /home in it?

Related: #959.

Thanks for filing this! Could I see the output of `findmnt -t btrfs --list` on your system? That's what borgmatic uses internally to probe for subvolume mount points. Based on the output above, I'm guessing it is finding `/home` correctly, but it'd be good to confirm. I would actually expect `/.borgmatic-snapshot-99638/home/` to be empty, because borgmatic doesn't do recursive snapshotting. Instead, I would expect it to do a separate snapshot of your `/home` subvolume mount point—if it's explicitly listed in your `source_directories`. So there's nothing in the output about `Creating Btrfs snapshot for /home subvolume`? And what happens if you omit `/` from `source_directories` but include `/home` in it? Related: #959.
Owner

Looking at this a little further, I think I found at least part of the problem. borgmatic is not expecting the @-prefixed names within the btrfs subvolume list output. Instead, it appears to be expecting valid filesystem mount point paths there. This means that it's not correctly seeing that the @home subvolume corresponds to the /home directory—and therefore it's not snapshotting /home. I'll have to think about how this can be addressed.

Looking at this a little further, I think I found at least part of the problem. borgmatic is not expecting the `@`-prefixed names within the `btrfs subvolume list` output. Instead, it appears to be expecting valid filesystem mount point paths there. This means that it's not correctly seeing that the `@home` subvolume corresponds to the `/home` directory—and therefore it's not snapshotting `/home`. I'll have to think about how this can be addressed.
Owner

I believe I have a fix in main, which will be part of the next release. Do you have any convenient way to test this fix locally, or would you prefer to wait for the release? The only changed file is here: https://projects.torsion.org/borgmatic-collective/borgmatic/raw/branch/main/borgmatic/hooks/data_source/btrfs.py ... In theory you could replace the corresponding file in your borgmatic installation to see if the fix works on your machine.

I believe I have a fix in main, which will be part of the next release. Do you have any convenient way to test this fix locally, or would you prefer to wait for the release? The only changed file is here: https://projects.torsion.org/borgmatic-collective/borgmatic/raw/branch/main/borgmatic/hooks/data_source/btrfs.py ... In theory you could replace the corresponding file in your borgmatic installation to see if the fix works on your machine.
Author

Thank you so much for the quick fix! I tried the the version from main and it works now.

hetzner: Snapshotting Btrfs subvolumes
hetzner: findmnt -t btrfs --json --list
hetzner: Creating Btrfs snapshot for / subvolume
hetzner: btrfs subvolume snapshot -r / /.borgmatic-snapshot-8646
Create readonly snapshot of '/' in '/.borgmatic-snapshot-8646'
hetzner: Creating Btrfs snapshot for /home subvolume
hetzner: btrfs subvolume snapshot -r /home /home/.borgmatic-snapshot-8646/home
Create readonly snapshot of '/home' in '/home/.borgmatic-snapshot-8646/home'
hetzner: Writing patterns to /run/user/0/borgmatic/tmpnayl4z0y:
R /.borgmatic-snapshot-8646/./
R /home/.borgmatic-snapshot-8646/./home

Really appreciate it :)

Thank you so much for the quick fix! I tried the the version from `main` and it works now. ``` hetzner: Snapshotting Btrfs subvolumes hetzner: findmnt -t btrfs --json --list hetzner: Creating Btrfs snapshot for / subvolume hetzner: btrfs subvolume snapshot -r / /.borgmatic-snapshot-8646 Create readonly snapshot of '/' in '/.borgmatic-snapshot-8646' hetzner: Creating Btrfs snapshot for /home subvolume hetzner: btrfs subvolume snapshot -r /home /home/.borgmatic-snapshot-8646/home Create readonly snapshot of '/home' in '/home/.borgmatic-snapshot-8646/home' hetzner: Writing patterns to /run/user/0/borgmatic/tmpnayl4z0y: R /.borgmatic-snapshot-8646/./ R /home/.borgmatic-snapshot-8646/./home ``` Really appreciate it :)
Owner

Awesome, glad to hear it!

Awesome, glad to hear it!
Owner

Released in borgmatic 1.9.9!

Released in borgmatic 1.9.9!
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
borgmatic-collective/borgmatic#983
No description provided.