Queue off-site transfers and protect their local sources
This commit is contained in:
1 parent
6b78db3684
commit
ab16c9db62
8 files changed
+345
-5
No files matched your search
@@ -33,6 +33,7 @@ from coulobre.mail_node import (
|
||||
MAX_MAILBOX_QUOTA_MIB,
|
||||
MailboxSpec,
|
||||
)
|
||||
from coulobre.offsite_backup import MAX_DESTINATION_LENGTH
|
||||
from coulobre.php_pool_settings import (
|
||||
PHP_SETTING_BOUNDS,
|
||||
PhpPoolSettings,
|
||||
@@ -1041,6 +1042,47 @@ class AccountBackupJob(ProvisioningJob):
|
||||
)
|
||||
|
||||
|
||||
class OffsiteBackupTransfer(ProvisioningJob):
|
||||
backup = models.OneToOneField(
|
||||
AccountBackupJob,
|
||||
on_delete=models.CASCADE,
|
||||
related_name="offsite_transfer",
|
||||
)
|
||||
destination = models.CharField(max_length=MAX_DESTINATION_LENGTH)
|
||||
next_attempt_at = models.DateTimeField(default=timezone.now)
|
||||
attempts = models.PositiveSmallIntegerField(default=0)
|
||||
verified_at = models.DateTimeField(null=True, blank=True)
|
||||
snapshot = models.CharField(max_length=64, blank=True)
|
||||
sha256 = models.CharField(max_length=64, blank=True)
|
||||
|
||||
class Meta:
|
||||
indexes = [models.Index(fields=("finished_at", "next_attempt_at"))]
|
||||
|
||||
@property
|
||||
def status(self):
|
||||
if self.verified_at is not None:
|
||||
return "Verified"
|
||||
if self.backup.finished_at is None:
|
||||
return "Waiting for local archive"
|
||||
if self.backup.problem:
|
||||
return "Local backup failed"
|
||||
if self.destination not in settings.OFFSITE_BACKUP_DESTINATIONS:
|
||||
return "Destination unavailable"
|
||||
if self.finished_at is not None:
|
||||
return "Failed"
|
||||
if self.started_at is not None:
|
||||
return "Transferring"
|
||||
if self.attempts:
|
||||
return "Retry scheduled"
|
||||
return "Queued"
|
||||
|
||||
@property
|
||||
def label(self):
|
||||
return settings.OFFSITE_BACKUP_DESTINATIONS.get(
|
||||
self.destination, self.destination
|
||||
)
|
||||
|
||||
|
||||
class AccountBackupExpiration(ProvisioningJob):
|
||||
backup = models.OneToOneField(
|
||||
AccountBackupJob, on_delete=models.CASCADE, related_name="expiration"
|
||||
@@ -1138,6 +1180,9 @@ class AccountBackupSchedule(models.Model):
|
||||
)
|
||||
time = models.TimeField("time (UTC)")
|
||||
include_mailboxes = models.BooleanField(default=False)
|
||||
offsite_destination = models.CharField(
|
||||
max_length=MAX_DESTINATION_LENGTH, blank=True
|
||||
)
|
||||
next_run_at = models.DateTimeField(null=True, blank=True)
|
||||
|
||||
class Meta:
|
||||
|
||||
Reference in new issue
Block a user