diff --git a/zfs_uploader/__init__.py b/zfs_uploader/__init__.py index 18b5f58..a214ad2 100644 --- a/zfs_uploader/__init__.py +++ b/zfs_uploader/__init__.py @@ -1,4 +1,4 @@ -__version__ = '0.8.0' +__version__ = '0.9.0' BACKUP_DB_FILE = 'backup.db' DATETIME_FORMAT = '%Y%m%d_%H%M%S' diff --git a/zfs_uploader/__main__.py b/zfs_uploader/__main__.py index 6399caa..ecae633 100644 --- a/zfs_uploader/__main__.py +++ b/zfs_uploader/__main__.py @@ -46,7 +46,9 @@ def cli(ctx, config_path, log_path): @cli.command() @click.pass_context def backup(ctx): - """ Start backup job scheduler. """ + """ Start backup job scheduler or run the tasks serially if + cron is not provided in the config file. + """ config_path = ctx.obj['config_path'] logger = ctx.obj['logger'] @@ -57,13 +59,19 @@ def backup(ctx): ) for job in config.jobs.values(): - logger.info(f'filesystem={job.filesystem} ' - f'cron="{job.cron}" ' - 'msg="Adding job."') - scheduler.add_job(job.start, 'cron', **job.cron, coalesce=True) + if job.cron: + logger.info(f'filesystem={job.filesystem} ' + f'cron="{job.cron}" ' + 'msg="Adding job."') + scheduler.add_job(job.start, 'cron', **job.cron, coalesce=True) + else: + logger.info(f'filesystem={job.filesystem}' + 'msg="Running job."') + job.start() try: - scheduler.start() + if len(scheduler.get_jobs()) > 0: + scheduler.start() except (KeyboardInterrupt, SystemExit): pass