feat(main): main

This commit is contained in:
2026-03-20 15:00:24 -04:00
parent af3076342a
commit c9718c5483
30 changed files with 2513 additions and 559 deletions

View File

@@ -0,0 +1,12 @@
from django.core.management.base import BaseCommand
from core.services.backups import create_backup_now
class Command(BaseCommand):
help = "Create a backup JSON under /Backups immediately."
def handle(self, *args, **options):
path = create_backup_now()
self.stdout.write(self.style.SUCCESS(f"Backup created: {path}"))

View File

@@ -0,0 +1,30 @@
import time
from django.core.management.base import BaseCommand
from core.models import BackupSchedule
from core.services.backups import create_backup_now, is_backup_due
class Command(BaseCommand):
help = "Continuously check backup schedule and run backups when due."
def add_arguments(self, parser):
parser.add_argument(
"--interval",
type=int,
default=60,
help="Polling interval in seconds (default: 60).",
)
def handle(self, *args, **options):
interval = options["interval"]
self.stdout.write(self.style.SUCCESS(f"Starting backup worker (interval={interval}s)"))
while True:
schedule = BackupSchedule.get_solo()
if schedule.enabled and is_backup_due(schedule):
path = create_backup_now()
self.stdout.write(self.style.SUCCESS(f"Backup created: {path.name}"))
time.sleep(interval)