Skip to content

Commit

Permalink
Merge pull request #68 from rdelcorro/rdelcorroFixEncryptedDataset
Browse files Browse the repository at this point in the history
Make backup cron setting optional
  • Loading branch information
ddebeau authored Jan 24, 2023
2 parents 10f0f89 + b4cb70f commit bc3d15b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion zfs_uploader/__init__.py
Original file line number Diff line number Diff line change
@@ -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'
20 changes: 14 additions & 6 deletions zfs_uploader/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']

Expand All @@ -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

Expand Down

0 comments on commit bc3d15b

Please sign in to comment.