45 lines
1.2 KiB
Python
45 lines
1.2 KiB
Python
from __future__ import annotations
|
|
|
|
import os
|
|
|
|
from pydantic import BaseSettings
|
|
|
|
|
|
def _ensure_dir(path: str) -> str:
|
|
os.makedirs(path, exist_ok=True)
|
|
return path
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
api_username: str = "backup-admin"
|
|
api_password: str = "SuperSecret123"
|
|
token_lifetime_minutes: int = 120
|
|
database_url: str = "sqlite:///./data/backup.db"
|
|
backup_base: str = "/srv/backup"
|
|
history_retention: int = 20
|
|
log_dir: str = "./logs"
|
|
ssh_timeout_seconds: int = 1800
|
|
ssh_pass_command: str = "sshpass"
|
|
ssh_extra_args: str = "-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
|
|
rsync_extra_args: str = "--info=progress2 --partial"
|
|
compress: bool = True
|
|
|
|
class Config:
|
|
env_file = os.path.join(os.path.dirname(__file__), "..", ".env")
|
|
env_file_encoding = "utf-8"
|
|
|
|
@property
|
|
def backup_current(self) -> str:
|
|
return _ensure_dir(os.path.join(self.backup_base, "current"))
|
|
|
|
@property
|
|
def backup_history(self) -> str:
|
|
return _ensure_dir(os.path.join(self.backup_base, ".history"))
|
|
|
|
@property
|
|
def runtime_logs(self) -> str:
|
|
return _ensure_dir(self.log_dir)
|
|
|
|
|
|
settings = Settings()
|