mirror of
https://github.com/kevinveenbirkenbach/docker-volume-backup.git
synced 2026-08-25 07:14:32 +00:00
feat(manifest)!: record per volume what the run established
A finished generation cannot show whether a volume held a database, nor whether a dump was produced for it: under --only-sql a failed dump falls back to a file copy, and the resulting files/ tree looks like any other copy. The run knows both and threw the knowledge away as a printed warning, leaving every reader to guess from file names. Each generation now carries a manifest.json stating its layout and, per volume, database / dumped / engine. baudolo.generation is the single place those names are spelled; restore/paths.py, backup/db.py and backup/volume.py stop repeating them. It is deliberately import-free so a consumer can read the manifest with nothing but json, on hosts where this package is not installed. BREAKING CHANGE: BackupException is renamed BackupError. The rename is atomic across the ten modules that define or import it, three of which also carry the manifest change, so it lands in this commit rather than a separate one that could not import. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -5,7 +5,9 @@ import os
|
||||
import pathlib
|
||||
from dataclasses import dataclass, field
|
||||
|
||||
from .shell import BackupException, execute_shell_command
|
||||
from baudolo.generation import FILES_DIR
|
||||
|
||||
from .shell import BackupError, execute_shell_command
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@@ -45,8 +47,8 @@ def get_last_backup_dir(
|
||||
) -> str | None:
|
||||
versions = sorted(os.listdir(versions_dir), reverse=True)
|
||||
for version in versions:
|
||||
candidate = os.path.join(versions_dir, version, volume_name, "files", "")
|
||||
if candidate != current_backup_dir and os.path.isdir(candidate):
|
||||
candidate = f"{pathlib.Path(versions_dir) / version / volume_name / FILES_DIR}/"
|
||||
if candidate != current_backup_dir and pathlib.Path(candidate).is_dir():
|
||||
return candidate
|
||||
return None
|
||||
|
||||
@@ -69,7 +71,7 @@ def backup_volume(
|
||||
source: directory to read from - the volume's mountpoint, or its path
|
||||
inside a snapshot.
|
||||
"""
|
||||
dest = os.path.join(volume_dir, "files") + "/"
|
||||
dest = f"{pathlib.Path(volume_dir) / FILES_DIR}/"
|
||||
pathlib.Path(dest).mkdir(parents=True, exist_ok=True)
|
||||
|
||||
last = get_last_backup_dir(versions_dir, volume_name, dest)
|
||||
@@ -82,7 +84,7 @@ def backup_volume(
|
||||
|
||||
try:
|
||||
execute_shell_command(cmd)
|
||||
except BackupException as e:
|
||||
except BackupError as e:
|
||||
if "file has vanished" in str(e):
|
||||
print(
|
||||
"Warning: Some files vanished before transfer. Continuing.", flush=True
|
||||
|
||||
Reference in New Issue
Block a user