Skip to content

Commit

Permalink
Fixes: #114 - Corrects logic to check if backup is scheduled.
Browse files Browse the repository at this point in the history
  • Loading branch information
DanSheps committed Feb 1, 2025
1 parent 678d8e3 commit 2d9c6b0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion netbox_config_backup/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ def ready(self, *args, **kwargs):
frequency = settings.PLUGINS_CONFIG.get('netbox_config_backup', {}).get('frequency') / 60
lastjob = BackupRunner.get_jobs().order_by('pk').last()

if lastjob.status in JobStatusChoices.ENQUEUED_STATE_CHOICES and lastjob.scheduled < timezone.now():
if not lastjob:
BackupRunner.enqueue_once(interval=frequency)
elif lastjob.status in JobStatusChoices.ENQUEUED_STATE_CHOICES and lastjob.scheduled < timezone.now():
BackupRunner.enqueue_once(interval=frequency)
elif lastjob.status in JobStatusChoices.TERMINAL_STATE_CHOICES:
scheduled = lastjob.created + timezone.timedelta(minutes=frequency)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ description = "A NetBox Switch Configuration Backup Plugin"
readme = "README.md"
requires-python = ">=3.10"
keywords = ["netbox-plugin", ]
version = "2.1.3"
version = "2.1.4"
license = {file = "LICENSE"}
classifiers = [
"Programming Language :: Python :: 3",
Expand Down

0 comments on commit 2d9c6b0

Please sign in to comment.