Make crontab configurable

This commit is contained in:
Einar Forselv
2019-12-08 06:38:56 +01:00
parent 1e21ff422f
commit ae835f30d3
6 changed files with 99 additions and 3 deletions

View File

@@ -10,7 +10,7 @@ from restic_compose_backup import (
)
from restic_compose_backup.config import Config
from restic_compose_backup.containers import RunningContainers
from restic_compose_backup import utils
from restic_compose_backup import cron, utils
logger = logging.getLogger(__name__)
@@ -48,6 +48,9 @@ def main():
import restic_compose_backup
print(restic_compose_backup.__version__)
elif args.action == "crontab":
crontab(config)
def status(config, containers):
"""Outputs the backup config for the compose setup"""
@@ -252,11 +255,25 @@ def alert(config, containers):
)
def crontab(config):
"""Generate the crontab"""
print(cron.generate_crontab(config))
def parse_args():
parser = argparse.ArgumentParser(prog='restic_compose_backup')
parser.add_argument(
'action',
choices=['status', 'snapshots', 'backup', 'start-backup-process', 'alert', 'cleanup', 'version'],
choices=[
'status',
'snapshots',
'backup',
'start-backup-process',
'alert',
'cleanup',
'version',
'crontab',
],
)
parser.add_argument(
'--log-level',