digint / digint/btrbk

Random fails with "File exists" error

Open
#644 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Perl
Stars
2.1k
Forks
139
PR merge metrics
No merged PRs in 30d

Description

I use btrbk with a systemd service that runs every night at midnight. Here is my configuration:

```
snapshot_preserve_min 3d

target_preserve_min no
target_preserve 20d 10w 6m

snapshot_dir @snapshots

volume /mnt/root
target /media/backup/root
subvolume @rootfs

volume /mnt/home
target /media/backup/home
subvolume @home

volume /mnt/raid
target /media/backup/raid
subvolume @
```

My subvolumes are mounted this way:

```
/mnt/root/@rootfs -> root partition, @rootfs subvolume (also mounted on /)
/mnt/root/@snapshots -> root partition, @snapshots subvolume
/mnt/home/@home -> home partition, @home subvolume (also mounted on /home)
/mnt/home/@snapshots -> home partition, @snapshots subvolume
/mnt/raid/@ -> raid partition, @ subvolume (also mounted on /media/raid)
/mnt/raid/@snapshots -> raid partition, @snapshots subvolume
/media/backup -> backup partition (with root, home and raid directories)
```

Almost every night, at least one of the three snapshots fails with the error "File exists" as shown in log below:

```
btrbk command line client, version 0.32.6 (Tue Apr 7 00:00:03 2026)
Using configuration: /etc/btrbk/btrbk.conf
Creating subvolume snapshot for: /mnt/root/@rootfs
[snapshot] source: /mnt/root/@rootfs
[snapshot] target: /mnt/root/@snapshots/@rootfs.20260407T0000
Creating subvolume snapshot for: /mnt/home/@home
[snapshot] source: /mnt/home/@home
[snapshot] target: /mnt/home/@snapshots/@home.20260407T0000
ERROR: Failed to create snapshot: /mnt/home/@home -> /mnt/home/@snapshots/@home.20260407T0000
ERROR: ... Command execution failed (exitcode=1)
ERROR: ... sh: btrfs subvolume snapshot -r '/mnt/home/@home' '/mnt/home/@snapshots/@home.20260407T0000'
ERROR: ... Could not create subvolume: File exists
WARNING: Skipping subvolume section: Failed to create snapshot: /mnt/home/@home -> /mnt/home/@snapshots/@home.20260407T0000
Creating subvolume snapshot for: /mnt/raid/@
[snapshot] source: /mnt/raid/@
[snapshot] target: /mnt/raid/@snapshots/@.20260407T0000
ERROR: Failed to create snapshot: /mnt/raid/@ -> /mnt/raid/@snapshots/@.20260407T0000
ERROR: ... Command execution failed (exitcode=1)
ERROR: ... sh: btrfs subvolume snapshot -r '/mnt/raid/@' '/mnt/raid/@snapshots/@.20260407T0000'
ERROR: ... Could not create subvolume: File exists
WARNING: Skipping subvolume section: Failed to create snapshot: /mnt/raid/@ -> /mnt/raid/@snapshots/@.20260407T0000
Checking for missing backups of subvolume "/mnt/root/@rootfs" in "/media/backup/root/"
Creating incremental backup...
[send/receive] target: /media/backup/root/@rootfs.20260407T0000
[send/receive] source: /mnt/root/@snapshots/@rootfs.20260407T0000
[send/receive] parent: /mnt/root/@snapshots/@rootfs.20260406T0000
[send/receive] checking target metadata: /media/backup/root/@rootfs.20260407T0000
Created 1/1 missing backups
Cleaning backups of subvolume "/mnt/root/@rootfs": /media/backup/root/@rootfs.*
[delete] target: /media/backup/root/@rootfs.20260317T0000
Deleted 1 subvolumes in: /media/backup/root/@rootfs.*
Cleaning snapshots: /mnt/root/@snapshots/@rootfs.*
[delete] target: /mnt/root/@snapshots/@rootfs.20260403T0000
[delete] target: /mnt/root/@snapshots/@rootfs.20260403T1503
Deleted 2 subvolumes in: /mnt/root/@snapshots/@rootfs.*
Completed within: 1s (Tue Apr 7 00:00:04 2026)
```

The strange thing is that snapshots _are_ created and sent to the backup partition. I don't know if they are complete, but when I run `btrbk resume` nothing happens.

Another strange thing: I can't reproduce the error when running `btrbk` manually (not with the systemd service). When I do that everything works as expected (the snapshots are created but not sent to backup as the one from the night is already there).

Do you see anything wrong with my setup that could cause those errors?

I can provide the systemd files if you want even though they are pretty basic (just a service calling `btrbk run` and a timer that launches it every night at midnight).

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the btrbk run and btrbk resume entry points, then compare the systemd service invocation with the manual command. Inspect the snapshot target paths and timestamps in the provided log to determine why an existing target is encountered only during the scheduled run. Done means identifying the cause and establishing whether the snapshots remain valid or the collision is prevented.

Written by the indexing model from the issue text.

Assessment

Tech stack
perl
Domain
cli, devops
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.