Queue account backups on daily and weekly schedules
This commit is contained in:
1 parent
1844271bba
commit
5c61ddc4cc
4 files changed
+195
-2
No files matched your search
@@ -445,6 +445,7 @@ class AccountBackupJob(ProvisioningJob):
|
||||
default=uuid.uuid4, unique=True, editable=False
|
||||
)
|
||||
manifest = models.JSONField()
|
||||
scheduled_for = models.DateTimeField(null=True, blank=True)
|
||||
|
||||
class Meta:
|
||||
indexes = [models.Index(fields=("finished_at", "requested_at"))]
|
||||
@@ -458,6 +459,40 @@ class AccountBackupJob(ProvisioningJob):
|
||||
return "mailboxes" in self.manifest
|
||||
|
||||
|
||||
class AccountBackupSchedule(models.Model):
|
||||
class Frequency(models.TextChoices):
|
||||
DAILY = "daily", "Daily"
|
||||
WEEKLY = "weekly", "Weekly"
|
||||
|
||||
class Weekday(models.IntegerChoices):
|
||||
MONDAY = 0, "Monday"
|
||||
TUESDAY = 1, "Tuesday"
|
||||
WEDNESDAY = 2, "Wednesday"
|
||||
THURSDAY = 3, "Thursday"
|
||||
FRIDAY = 4, "Friday"
|
||||
SATURDAY = 5, "Saturday"
|
||||
SUNDAY = 6, "Sunday"
|
||||
|
||||
account = models.OneToOneField(
|
||||
HostingAccount,
|
||||
on_delete=models.CASCADE,
|
||||
related_name="backup_schedule",
|
||||
)
|
||||
enabled = models.BooleanField(default=True)
|
||||
frequency = models.CharField(
|
||||
max_length=6, choices=Frequency, default=Frequency.DAILY
|
||||
)
|
||||
weekday = models.PositiveSmallIntegerField(
|
||||
choices=Weekday, null=True, blank=True
|
||||
)
|
||||
time = models.TimeField("time (UTC)")
|
||||
include_mailboxes = models.BooleanField(default=False)
|
||||
next_run_at = models.DateTimeField(null=True, blank=True)
|
||||
|
||||
class Meta:
|
||||
indexes = [models.Index(fields=("enabled", "next_run_at"))]
|
||||
|
||||
|
||||
class DnsPublication(ProvisioningJob):
|
||||
zone = models.OneToOneField(
|
||||
HostingDnsZone, on_delete=models.CASCADE, related_name="publication"
|
||||
|
||||
Reference in new issue
Block a user