mirror of
https://github.com/kevinveenbirkenbach/docker-volume-backup.git
synced 2026-08-02 13:02:41 +00:00
fix(backup): carve the btrfs snapshot inside its subject, not beside it
The kernel refuses a snapshot whose destination sits on another filesystem. Placing it at <parent>/.baudolo-<tag> hit that on the most sensible layout there is: a dedicated disk mounted straight onto /var/lib/docker, where the parent directory belongs to a different filesystem and every run failed with EXDEV. Placing it at <subject>/.baudolo-<tag> makes source and destination the same filesystem by construction, so the failure cannot occur on any layout. It also aligns the two backends: the zfs path already resolves its snapshot inside the subject, at <subject>/.zfs/snapshot/<tag>. btrfs does not include nested subvolumes in a snapshot, so a leftover from an interrupted run appears in the next snapshot as an empty directory rather than recursing, and the copy only ever reads the volume tree below it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -41,7 +41,10 @@ def _resolver(subject: str, root: str) -> Callable[[str], str]:
|
||||
|
||||
|
||||
def _btrfs(subject: str, name: str, run: Callable[[str], list[str]]) -> tuple[str, str]:
|
||||
target = os.path.join(os.path.dirname(os.path.abspath(subject)), f".{name}")
|
||||
# The snapshot goes inside the subject, never beside it: the kernel rejects
|
||||
# a snapshot whose destination is on another filesystem, which is exactly
|
||||
# what the parent directory is when the subject is a mountpoint of its own.
|
||||
target = os.path.join(os.path.abspath(subject), f".{name}")
|
||||
run(f"btrfs subvolume snapshot -r {subject} {target}")
|
||||
return target, f"btrfs subvolume delete {target}"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user