From f6ce330d56e813aa17fcb471eb804751afc2193c Mon Sep 17 00:00:00 2001 From: Einar Forselv Date: Mon, 15 Apr 2019 17:25:42 +0200 Subject: [PATCH] Split up modules --- restic_volume_backup/{backup.py => cli.py} | 23 ++-------------------- restic_volume_backup/config.py | 19 ++++++++++++++++++ 2 files changed, 21 insertions(+), 21 deletions(-) rename restic_volume_backup/{backup.py => cli.py} (68%) create mode 100644 restic_volume_backup/config.py diff --git a/restic_volume_backup/backup.py b/restic_volume_backup/cli.py similarity index 68% rename from restic_volume_backup/backup.py rename to restic_volume_backup/cli.py index ad5a89c..791b38a 100644 --- a/restic_volume_backup/backup.py +++ b/restic_volume_backup/cli.py @@ -1,22 +1,5 @@ -import os -import sys -from containers import RunningContainers -import restic - -cmds = ['status', 'backup', 'snapshots', 'check'] - - -class Config: - repository = os.environ['RESTIC_REPOSITORY'] - password = os.environ['RESTIC_PASSWORD'] - - @classmethod - def check(cls): - if not cls.repository: - raise ValueError("CONTAINER env var not set") - - if not cls.password: - raise ValueError("PASSWORD env var not set") +from restic_volume_backup.config import Config +from restic_volume_backup.containers import RunningContainers def main(): @@ -51,8 +34,6 @@ def main(): # for vol in containers.backup_volumes(): # restic.backup_volume(Config.repository, vol) - - if mode == 'snapshots': restic.snapshots(Config.repository) diff --git a/restic_volume_backup/config.py b/restic_volume_backup/config.py new file mode 100644 index 0000000..8883bc1 --- /dev/null +++ b/restic_volume_backup/config.py @@ -0,0 +1,19 @@ +import os +import sys +from containers import RunningContainers +import restic + +cmds = ['status', 'backup', 'snapshots', 'check'] + + +class Config: + repository = os.environ['RESTIC_REPOSITORY'] + password = os.environ['RESTIC_PASSWORD'] + + @classmethod + def check(cls): + if not cls.repository: + raise ValueError("CONTAINER env var not set") + + if not cls.password: + raise ValueError("PASSWORD env var not set")