Commit 28842d25 authored by Tim Bleimehl's avatar Tim Bleimehl 🤸🏼
Browse files

wip

parent 2934cbf6
......@@ -17,7 +17,6 @@ log = logging.getLogger("databasebackupper")
"""
Todo:
Refactor:
* Make backup dict into a class
* tidy up, simplfy
......
......@@ -4,7 +4,7 @@ import click
import os
import sys
from typing import Dict, List, Type
from pathlib import Path
from pathlib import Path, PurePath
if __name__ == "__main__":
SCRIPT_DIR = os.path.dirname(
......@@ -204,6 +204,18 @@ def backup(target_dir):
databases = None
else:
databases = config_labels[ValidLabels.database_names].val.split(",")
bu.retention.retention_duration = {
RetentionType.DAILY: config_labels[ValidLabels.retention_daily].val,
RetentionType.WEEKLY: config_labels[ValidLabels.retention_weekly].val,
RetentionType.MONTHLY: config_labels[ValidLabels.retention_monthly].val,
RetentionType.YEARLY: config_labels[ValidLabels.retention_yearly].val,
RetentionType.MANUAL: config_labels[ValidLabels.retention_manual].val,
}
bu.retention.base_path = Path(
PurePath(
bu.retention.base_path, config_labels[ValidLabels.backup_subdir].val
)
)
bu.backup(
databases=databases,
retention_type=RetentionType.DAILY,
......
......@@ -43,6 +43,28 @@ class ValidLabels:
database_password: Label = Label("password", str)
database_host: Label = Label("host", str, default="127.0.0.1")
database_names: Label = Label("databases", str)
backup_subdir: Label = Label("backup_subdir", str, default="")
retention_daily: Label = Label(
"retention_daily", int, default=config.RETENTION_KEEP_NUMBER_OF_DAILY_BACKUPS
)
retention_weekly: Label = Label(
"retention_weekly", int, default=config.RETENTION_KEEP_NUMBER_OF_WEEKLY_BACKUPS
)
retention_monthly: Label = Label(
"retention_monthly",
int,
default=config.RETENTION_KEEP_NUMBER_OF_MONTHLY_BACKUPS,
)
retention_yearly: Label = Label(
"retention_yearly",
int,
default=config.RETENTION_KEEP_NUMBER_OF_YEARLY_BACKUPS,
)
retention_manual: Label = Label(
"retention_manual",
int,
default=config.RETENTION_KEEP_NUMBER_OF_MANUAL_BACKUPS,
)
@classmethod
def iter(cls) -> List[Label]:
......
......@@ -2,7 +2,7 @@ import logging
from Configs import getConfig
from config import DEFAULT
from sqlbackupper.backupper import DatabaseBackupper
from backupper import DatabaseBackupper
from executer import Executer
from backup_manager import BackupManager, RetentionType
from container_helper import ContainerHelper
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment