mirror of
https://github.com/kevinveenbirkenbach/docker-volume-backup.git
synced 2026-08-01 12:34:50 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c2f1cb8e8c | |||
| eeaa838d02 |
13
CHANGELOG.md
13
CHANGELOG.md
@@ -1,5 +1,18 @@
|
||||
# Changelog
|
||||
|
||||
## [3.2.2] - 2026-07-31
|
||||
|
||||
- Backup: the btrfs snapshot is carved inside its subject, as
|
||||
*<data root>/.baudolo-<tag>*, not beside it. The kernel refuses a snapshot
|
||||
whose destination is on another filesystem, which is exactly what the parent
|
||||
directory is when the data root is a mountpoint of its own — a dedicated disk
|
||||
mounted onto */var/lib/docker* failed every run with EXDEV. Placing it inside
|
||||
makes source and destination the same filesystem by construction, and aligns
|
||||
btrfs with the zfs path, which already resolves its snapshot inside the
|
||||
subject at *<subject>/.zfs/snapshot/<tag>*. A leftover from an interrupted run
|
||||
appears in the next snapshot as an empty directory rather than recursing,
|
||||
since btrfs does not include nested subvolumes.
|
||||
|
||||
## [3.2.1] - 2026-07-31
|
||||
|
||||
- Backup: the snapshot resolver keeps the trailing separator *get_storage_path*
|
||||
|
||||
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "backup-docker-to-local"
|
||||
version = "3.2.1"
|
||||
version = "3.2.2"
|
||||
description = "Backup Docker volumes to local with rsync and optional DB dumps."
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.9"
|
||||
|
||||
@@ -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}"
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ class TestSnapshotBranch(unittest.TestCase):
|
||||
|
||||
def test_it_reads_from_the_snapshot_and_not_from_the_live_tree(self) -> None:
|
||||
source = drive(present=True)[0]["source"]
|
||||
self.assertTrue(source.startswith("/var/lib/.baudolo-"), source)
|
||||
self.assertTrue(source.startswith("/var/lib/docker/.baudolo-"), source)
|
||||
|
||||
def test_it_compares_by_content_against_the_previous_generation(self) -> None:
|
||||
self.assertTrue(drive(present=True)[0]["authoritative"])
|
||||
|
||||
@@ -22,27 +22,27 @@ class Runner:
|
||||
|
||||
|
||||
class TestBtrfs(unittest.TestCase):
|
||||
def test_it_creates_a_read_only_snapshot_beside_the_subject(self) -> None:
|
||||
def test_it_creates_a_read_only_snapshot_inside_the_subject(self) -> None:
|
||||
run = Runner()
|
||||
with volume_snapshot("btrfs", "/var/lib/docker", "20260731", run=run):
|
||||
pass
|
||||
self.assertEqual(
|
||||
run.calls[0],
|
||||
"btrfs subvolume snapshot -r /var/lib/docker /var/lib/.baudolo-20260731",
|
||||
"btrfs subvolume snapshot -r /var/lib/docker /var/lib/docker/.baudolo-20260731",
|
||||
)
|
||||
|
||||
def test_it_removes_the_snapshot_afterwards(self) -> None:
|
||||
run = Runner()
|
||||
with volume_snapshot("btrfs", "/var/lib/docker", "20260731", run=run):
|
||||
pass
|
||||
self.assertEqual(run.calls[-1], "btrfs subvolume delete /var/lib/.baudolo-20260731")
|
||||
self.assertEqual(run.calls[-1], "btrfs subvolume delete /var/lib/docker/.baudolo-20260731")
|
||||
|
||||
def test_it_maps_a_volume_path_into_the_snapshot(self) -> None:
|
||||
run = Runner()
|
||||
with volume_snapshot("btrfs", "/var/lib/docker", "20260731", run=run) as resolve:
|
||||
self.assertEqual(
|
||||
resolve("/var/lib/docker/volumes/postgres_data/_data"),
|
||||
"/var/lib/.baudolo-20260731/volumes/postgres_data/_data",
|
||||
"/var/lib/docker/.baudolo-20260731/volumes/postgres_data/_data",
|
||||
)
|
||||
|
||||
def test_it_keeps_the_trailing_slash_rsync_reads_as_contents(self) -> None:
|
||||
@@ -50,7 +50,7 @@ class TestBtrfs(unittest.TestCase):
|
||||
with volume_snapshot("btrfs", "/var/lib/docker", "20260731", run=run) as resolve:
|
||||
self.assertEqual(
|
||||
resolve("/var/lib/docker/volumes/postgres_data/_data/"),
|
||||
"/var/lib/.baudolo-20260731/volumes/postgres_data/_data/",
|
||||
"/var/lib/docker/.baudolo-20260731/volumes/postgres_data/_data/",
|
||||
)
|
||||
|
||||
def test_it_removes_the_snapshot_even_when_the_body_raises(self) -> None:
|
||||
@@ -109,7 +109,7 @@ class TestRejections(unittest.TestCase):
|
||||
def test_the_subject_itself_resolves_to_the_snapshot_root(self) -> None:
|
||||
run = Runner()
|
||||
with volume_snapshot("btrfs", "/var/lib/docker", "20260731", run=run) as resolve:
|
||||
self.assertEqual(resolve("/var/lib/docker"), "/var/lib/.baudolo-20260731")
|
||||
self.assertEqual(resolve("/var/lib/docker"), "/var/lib/docker/.baudolo-20260731")
|
||||
|
||||
|
||||
class Busy(Runner):
|
||||
|
||||
Reference in New Issue
Block a user