From 0e96b5030db55f39ed1aa3f80f4fbac417c6f61e Mon Sep 17 00:00:00 2001 From: Anton Vakhrushev Date: Sat, 20 Dec 2025 21:04:54 +0300 Subject: [PATCH] Backup: refactoring --- files/backups/backup-all.py | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/files/backups/backup-all.py b/files/backups/backup-all.py index 18880bf..b1d2df2 100644 --- a/files/backups/backup-all.py +++ b/files/backups/backup-all.py @@ -16,6 +16,14 @@ from typing import Dict, List, Optional import requests import tomllib +CONFIG_PATH = Path("/etc/backup/config.toml") + +# File name to store directories and files to back up +BACKUP_TARGETS_FILE = "backup-targets" + +# Default directory fo backups (relative to app dir) +# Used when backup-targets file not exists +BACKUP_DEFAULT_DIR = "backups" # Configure logging logging.basicConfig( @@ -54,6 +62,12 @@ class Config: notifications: Dict[str, TelegramConfig] +@dataclass +class Application: + path: Path + owner: str + + class ResticStorage: def __init__(self, cfg: StorageConfig): if cfg.type != "restic": @@ -130,22 +144,6 @@ class ResticStorage: return False -CONFIG_PATH = Path("/etc/backup/config.toml") - -# File name to store directories and files to back up -BACKUP_TARGETS_FILE = "backup-targets" - -# Default directory fo backups (relative to app dir) -# Used when backup-targets file not exists -BACKUP_DEFAULT_DIR = "backups" - - -@dataclass -class Application: - path: Path - owner: str - - class BackupManager: def __init__(self, config: Config, storage: ResticStorage): self.errors: List[str] = []