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 +15 -0
- bdbackup/backends.py +56 -0
- bdbackup/cli.py +1045 -0
- bdbackup/config.py +114 -0
- bdbackup/dboperations.py +88 -0
- bdbackup/engines.py +167 -0
- bdbackup/filebackup.py +305 -0
- bdbackup/history.py +180 -0
- bdbackup/mysql/__init__.py +26 -0
- bdbackup/mysql/helpers.py +50 -0
- bdbackup/mysql/mysqldump.py +161 -0
- bdbackup/mysql/xtrabackup.py +471 -0
- bdbackup/recovery.py +80 -0
- bdbackup/retention.py +636 -0
- bdbackup/scheduling.py +196 -0
- bdbackup/templates/__init__.py +163 -0
- bdbackup/templates/_matching.py +159 -0
- bdbackup/templates/python_dev.py +54 -0
- bdbackup/utils.py +58 -0
- bdbackup/validation.py +400 -0
- bdbackup-0.6.1.dist-info/METADATA +752 -0
- bdbackup-0.6.1.dist-info/RECORD +25 -0
- bdbackup-0.6.1.dist-info/WHEEL +4 -0
- bdbackup-0.6.1.dist-info/entry_points.txt +2 -0
- bdbackup-0.6.1.dist-info/licenses/LICENSE +21 -0
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)
|