""" Backup system configuration schema. Supports Restic, BorgBackup, Tar, Rsync with retention policies and scheduling. """ schema TypesBackup: BackendType: "restic" | "borg" | "tar" | "rsync" | "cpio" RepositoryType: "local" | "s3" | "sftp" | "rest" | "b2" schema RetentionPolicy: """Backup retention policy""" # Keep daily backups for N days daily_days: int = 7 # Keep weekly backups for N weeks weekly_weeks: int = 4 # Keep monthly backups for N months monthly_months: int = 12 # Keep yearly backups for N years yearly_years: int = 5 check: daily_days > 0, "daily_days must be positive" weekly_weeks > 0, "weekly_weeks must be positive" monthly_months > 0, "monthly_months must be positive" yearly_years > 0, "yearly_years must be positive" schema Repository: """Backup repository configuration""" type: TypesBackup.RepositoryType # Local filesystem path?: str # S3 bucket bucket?: str prefix?: str = "" # SFTP server host?: str sftp_path?: str # REST API endpoint url?: str check: (type == "local" and path != None) or \ (type == "s3" and bucket != None) or \ (type == "sftp" and host != None and sftp_path != None) or \ (type == "rest" and url != None) or \ (type == "b2" and bucket != None), \ "Repository configuration mismatch with type" schema BackupJob: """Backup job configuration""" # Job name name: str # Backend to use backend: TypesBackup.BackendType = "restic" # Repository configuration repository: Repository # Paths to backup paths: [str] # Retention policy retention: RetentionPolicy = { daily_days = 7 weekly_weeks = 4 monthly_months = 12 yearly_years = 5 } # Pre-backup hook pre_backup_hook?: str # Post-backup hook post_backup_hook?: str # Exclude patterns exclude_patterns?: [str] # Compression level (0-9) compression: int = 3 check: len(name) > 0, "name must not be empty" len(paths) > 0, "paths must not be empty" compression >= 0 and compression <= 9, "compression must be 0-9" schema BackupSchedule: """Backup scheduling configuration""" # Schedule name name: str # Job to schedule job: BackupJob # Cron expression cron: str # Enabled enabled: bool = True # Maximum concurrent backups max_concurrent: int = 1 check: len(name) > 0, "name must not be empty" len(cron) > 0, "cron must not be empty" max_concurrent > 0, "max_concurrent must be positive" schema BackupConfig: """Global backup configuration""" # Default backend default_backend: TypesBackup.BackendType = "restic" # Default repository default_repository: Repository # Jobs to configure jobs: [BackupJob] # Schedules schedules: [BackupSchedule] = [] # Enable backup verification verify_after_backup: bool = True check: len(jobs) >= 0, "jobs must be a valid list" # Global backup configuration backup_config: BackupConfig = { default_backend = "restic" default_repository = { type = "local" path = "./backups" } jobs = [] schedules = [] verify_after_backup = True }