bdbackup 0.6.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
bdbackup/__init__.py ADDED
@@ -0,0 +1,15 @@
1
+ """bdbackup: file and database backups with verification, retention, and guided recovery."""
2
+
3
+ from importlib.metadata import version
4
+
5
+ from bdbackup.filebackup import FileBackup
6
+ from bdbackup.mysql import MySQLBackup, XtraBackup
7
+
8
+ __version__ = version("bdbackup")
9
+
10
+ __all__ = [
11
+ "FileBackup",
12
+ "MySQLBackup",
13
+ "XtraBackup",
14
+ "__version__",
15
+ ]
bdbackup/backends.py ADDED
@@ -0,0 +1,56 @@
1
+ """Backend abstractions for bdbackup."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import logging
6
+ from dataclasses import dataclass
7
+ from pathlib import Path
8
+ from typing import Protocol, runtime_checkable
9
+
10
+
11
+ @dataclass
12
+ class BackupResult:
13
+ """Outcome of a backup run."""
14
+
15
+ path: Path
16
+ size_bytes: int = 0
17
+ duration_seconds: float = 0.0
18
+ success: bool = False
19
+
20
+
21
+ class BackupError(Exception):
22
+ """Raised when a backup or verification fails."""
23
+
24
+
25
+ @runtime_checkable
26
+ class BackupBackend(Protocol):
27
+ """Contract for a backup implementation."""
28
+
29
+ def backup(self, name: str | None = None) -> BackupResult:
30
+ """Run the backup and return a result object."""
31
+ ...
32
+
33
+ def verify(self, result: BackupResult | None = None) -> BackupResult:
34
+ """Verify a previously produced backup."""
35
+ ...
36
+
37
+ def prune(self) -> list[Path]:
38
+ """Remove old backups according to the backend's retention policy."""
39
+ ...
40
+
41
+
42
+ def setup_logging(level: int = logging.INFO) -> None:
43
+ """Configure the root bdbackup logger exactly once.
44
+
45
+ Module-level loggers are left without handlers; they propagate to this root.
46
+ """
47
+ root = logging.getLogger("bdbackup")
48
+ root.setLevel(level)
49
+ if not root.handlers:
50
+ handler = logging.StreamHandler()
51
+ handler.setLevel(logging.NOTSET)
52
+ formatter = logging.Formatter(
53
+ "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
54
+ )
55
+ handler.setFormatter(formatter)
56
+ root.addHandler(handler)