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:
@@ -1,7 +1,9 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
|
||||
from baudolo.generation import CLUSTER_SUFFIX, DUMP_SUFFIX, FILES_DIR, SQL_DIR
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@@ -14,20 +16,20 @@ class BackupPaths:
|
||||
|
||||
def root(self) -> str:
|
||||
# Always build an absolute path under backups_dir
|
||||
return os.path.join(
|
||||
self.backups_dir,
|
||||
self.backup_hash,
|
||||
self.repo_name,
|
||||
self.version,
|
||||
self.volume_name,
|
||||
return str(
|
||||
Path(self.backups_dir)
|
||||
/ self.backup_hash
|
||||
/ self.repo_name
|
||||
/ self.version
|
||||
/ self.volume_name
|
||||
)
|
||||
|
||||
def files_dir(self) -> str:
|
||||
return os.path.join(self.root(), "files")
|
||||
return str(Path(self.root()) / FILES_DIR)
|
||||
|
||||
def sql_file(self, db_name: str) -> str:
|
||||
return os.path.join(self.root(), "sql", f"{db_name}.backup.sql")
|
||||
return str(Path(self.root()) / SQL_DIR / f"{db_name}{DUMP_SUFFIX}")
|
||||
|
||||
def cluster_file(self, instance: str) -> str:
|
||||
"""The pg_dumpall stream a `database = '*'` row produces."""
|
||||
return os.path.join(self.root(), "sql", f"{instance}.cluster.backup.sql")
|
||||
return str(Path(self.root()) / SQL_DIR / f"{instance}{CLUSTER_SUFFIX}")
|
||||
|
||||
Reference in New Issue
Block a user