-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
24 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,28 @@ | ||
import uuid | ||
|
||
from django.core.management.base import BaseCommand | ||
from django.db import transaction | ||
from django.utils import timezone | ||
|
||
from netbox_config_backup.models import BackupJob | ||
from netbox_config_backup.utils.rq import can_backup | ||
from netbox_config_backup.jobs.backup import BackupRunner | ||
from netbox_config_backup.models import Backup | ||
|
||
|
||
class Command(BaseCommand): | ||
def add_arguments(self, parser): | ||
parser.add_argument('--time', dest='time', help="time") | ||
parser.add_argument('--device', dest='device', help="Device Name") | ||
|
||
def run_backup(self, backup=None): | ||
BackupRunner.enqueue(backup=backup, immediate=True) | ||
|
||
def handle(self, *args, **options): | ||
from netbox_config_backup.models import Backup | ||
if options['device']: | ||
print(f'Running:{options.get("device")}| ') | ||
print(f'Running backup for: {options.get("device")}') | ||
backup = Backup.objects.filter(device__name=options['device']).first() | ||
if not backup: | ||
backup = Backup.objects.filter(name=options['device']).first() | ||
if backup: | ||
self.run_backup(backup) | ||
else: | ||
raise Exception('Device not found') | ||
else: | ||
for backup in Backup.objects.all(): | ||
self.run_backup(backup) | ||
pass | ||
#self.run_backup() | ||
|