restic-compose-backup/restic_compose_backup/config.py

30 lines
947 B
Python
Raw Normal View History

2019-04-15 15:25:42 +00:00
import os
class Config:
2019-11-15 13:23:56 +00:00
"""Bag for config values"""
2019-04-16 16:21:42 +00:00
def __init__(self, check=True):
2019-12-04 22:25:15 +00:00
# Mandatory values
self.repository = os.environ.get('RESTIC_REPOSITORY')
self.password = os.environ.get('RESTIC_REPOSITORY')
self.docker_base_url = os.environ.get('DOCKER_BASE_URL') or "unix://tmp/docker.sock"
2019-11-12 11:39:49 +00:00
2019-12-04 23:38:09 +00:00
# Log
self.log_level = os.environ.get('LOG_LEVEL')
2019-12-04 22:25:15 +00:00
# forget / keep
self.keep_daily = os.environ.get('KEEP_DAILY') or "7"
self.keep_weekly = os.environ.get('KEEP_WEEKLY') or "4"
self.keep_monthly = os.environ.get('KEEP_MONTHLY') or "12"
self.keep_yearly = os.environ.get('KEEP_YEARLY') or "3"
2019-04-16 16:21:42 +00:00
if check:
self.check()
2019-04-15 15:25:42 +00:00
def check(self):
if not self.repository:
2019-12-04 22:25:15 +00:00
raise ValueError("RESTIC_REPOSITORY env var not set")
2019-04-15 15:25:42 +00:00
if not self.password:
2019-12-04 22:25:15 +00:00
raise ValueError("RESTIC_REPOSITORY env var not set")