diff --git a/deploy/panel.env.example b/deploy/panel.env.example index febafb9..b9a1df7 100644 --- a/deploy/panel.env.example +++ b/deploy/panel.env.example @@ -16,3 +16,4 @@ COULOBRE_BROKER_URL=amqp://coulobre:@127.0.0.1:5672/coulobre # COULOBRE_LOCAL_MAILBOX_PROVISIONING=1 # COULOBRE_LOCAL_ACCOUNT_BACKUPS=1 # COULOBRE_LOCAL_ACCOUNT_BACKUP_MAIL=1 +# COULOBRE_LOCAL_WEBSITE_RESTORE=1 diff --git a/deploy/systemd/coulobre-account-restore.socket b/deploy/systemd/coulobre-account-restore.socket new file mode 100644 index 0000000..ffce980 --- /dev/null +++ b/deploy/systemd/coulobre-account-restore.socket @@ -0,0 +1,11 @@ +[Unit] +Description=Coulobre local website restore socket + +[Socket] +ListenStream=/run/coulobre-account-restore.sock +SocketUser=root +SocketGroup=coulobre-restore-requests +SocketMode=0660 +Accept=yes +MaxConnections=4 +RemoveOnStop=true diff --git a/deploy/systemd/coulobre-account-restore@.service b/deploy/systemd/coulobre-account-restore@.service new file mode 100644 index 0000000..d75e1b3 --- /dev/null +++ b/deploy/systemd/coulobre-account-restore@.service @@ -0,0 +1,22 @@ +[Unit] +Description=Coulobre local website restore request +CollectMode=inactive-or-failed + +[Service] +Type=exec +User=root +WorkingDirectory=/opt/coulobre +StateDirectory=coulobre/account-restores +StateDirectoryMode=0700 +ReadWritePaths=-/srv/coulobre/web +UMask=0077 +ExecStart=/opt/coulobre/bin/coulobre-account-backup restore-website-request +StandardInput=socket +StandardOutput=socket +StandardError=journal +RuntimeMaxSec=30min +NoNewPrivileges=true +CapabilityBoundingSet=~CAP_SYS_RESOURCE +PrivateTmp=true +ProtectHome=true +ProtectSystem=strict diff --git a/deploy/systemd/coulobre-backup-worker.service.d/restore.conf b/deploy/systemd/coulobre-backup-worker.service.d/restore.conf new file mode 100644 index 0000000..9d722f2 --- /dev/null +++ b/deploy/systemd/coulobre-backup-worker.service.d/restore.conf @@ -0,0 +1,6 @@ +[Unit] +Requires=coulobre-account-restore.socket +After=coulobre-account-restore.socket + +[Service] +SupplementaryGroups=coulobre-restore-requests diff --git a/docs/deployment.md b/docs/deployment.md index 56cabdd..cc8389d 100644 --- a/docs/deployment.md +++ b/docs/deployment.md @@ -420,6 +420,48 @@ most one missed backup per account and continues with the next future time. Scheduled ZIPs are stored alongside manual backups and require the same server-side retention management. +#### Restore website files from the panel + +Enable this feature when the website and account backup archive are on the +same server. Install the restore socket and give the backup worker access to +it. + +```sh +sudo groupadd --system coulobre-restore-requests +sudo install -m 0644 deploy/systemd/coulobre-account-restore.socket \ + deploy/systemd/coulobre-account-restore@.service /etc/systemd/system/ +sudo install -D -m 0644 deploy/systemd/coulobre-backup-worker.service.d/restore.conf \ + /etc/systemd/system/coulobre-backup-worker.service.d/restore.conf +sudo systemctl daemon-reload +``` + +Set `COULOBRE_LOCAL_WEBSITE_RESTORE=1` in `/etc/coulobre/panel.env`. + +```sh +panel_manage migrate --noinput +sudo systemctl restart coulobre-panel coulobre-worker coulobre-backup-worker +``` + +Select **Restore website** on a completed backup for the current account and +domain. Operators need the backup permissions listed above and **Can add +website restore job**. A backup that includes mail also requires permission +to view mailbox requests. + +For one file, enter its path relative to the document root. Make sure the +parent directory exists. Select **Replace the existing file at this path** +only if an existing site-owned file should be overwritten. Choose **Entire +website** to restore all website files to an empty document root. When +replacing a file, its old and restored copies must fit within the website's +storage quota during staging. The **Website restores** section records the +source backup, operator, and result. + +Restore request records under `/var/lib/coulobre/account-restores/` prevent +an interrupted worker from applying the same restore twice. Keep these +records while corresponding jobs could still be delivered. If the panel +cannot confirm a restore, check the destination before submitting another. +Use the [account bundle commands](development.md#recover-backups-from-the-bundle) +to recover databases, mail, or components on separate servers. + #### Include mailboxes on the same server Complete the [Postfix and Dovecot setup](development.md#apply-a-mailbox-manifest) diff --git a/docs/development.md b/docs/development.md index 9723eed..fe4cbc2 100644 --- a/docs/development.md +++ b/docs/development.md @@ -1073,6 +1073,10 @@ sudo /opt/coulobre/bin/coulobre-account-backup pack \ ### Recover backups from the bundle +On a single-server installation, operators can restore one file or the entire +website from a completed account backup. See +[restoring from the panel](deployment.md#restore-website-files-from-the-panel). + Unpack to a new directory on a root-controlled path. The command verifies the ZIP contents and checks the identity and integrity of each compressed component before publishing the directory. diff --git a/src/coulobre/account_backup.py b/src/coulobre/account_backup.py index 9452453..de0009b 100644 --- a/src/coulobre/account_backup.py +++ b/src/coulobre/account_backup.py @@ -4,6 +4,7 @@ import json import os import tarfile import zlib +from contextlib import contextmanager from dataclasses import dataclass from pathlib import Path from shutil import copyfileobj @@ -121,8 +122,17 @@ def main(argv=None): commands.add_parser( "create-request", help="Create a local backup for the panel worker." ) + commands.add_parser( + "restore-website-request", + help="Restore website files for the panel worker.", + ) args = parser.parse_args(argv) + if args.command == "restore-website-request": + from .account_restore_request import serve_website_restore + + return serve_website_restore() + if args.command == "create-request": from .account_backup_request import serve_backup_request @@ -201,15 +211,11 @@ def pack_backup(backup, directory, archive): os.link(staged.name, archive) -def unpack_backup(archive, directory): +@contextmanager +def open_account_bundle(archive): archive = private_path(archive) check_root_file(archive, mode=0o600) - directory = private_path(directory, new=True) - with ( - ZipFile(archive) as bundle, - TemporaryDirectory(dir=directory.parent) as temporary, - ): - staged = Path(temporary) + with ZipFile(archive) as bundle: entries = bundle.infolist() if any( entry.compress_type != ZIP_STORED or entry.flag_bits & 1 @@ -226,6 +232,16 @@ def unpack_backup(archive, directory): with bundle.open(manifests[0]) as source: backup = read_backup_manifest(source) validate_bundle_entries(entries, backup) + yield bundle, backup + + +def unpack_backup(archive, directory): + directory = private_path(directory, new=True) + with ( + open_account_bundle(archive) as (bundle, backup), + TemporaryDirectory(dir=directory.parent) as temporary, + ): + staged = Path(temporary) write_new_file( staged / MANIFEST_NAME, manifest_text(backup), mode=0o600 ) diff --git a/src/coulobre/account_backup_request.py b/src/coulobre/account_backup_request.py index df75c80..8211125 100644 --- a/src/coulobre/account_backup_request.py +++ b/src/coulobre/account_backup_request.py @@ -12,7 +12,7 @@ from .account_backup import ( read_backup_manifest, ) from .database_node import DEFAULT_SOCKET -from .node_files import check_root_file, require_root_directory +from .node_files import check_root_file, locked_root_directory from .node_requests import serve_apply_request REQUEST_VERSION = 1 @@ -71,8 +71,6 @@ def serve_backup_request(): def create_requested_backup(request): - import fcntl - if os.geteuid() != 0: raise ValueError("Run create-request as root on the backup node.") if ( @@ -80,15 +78,8 @@ def create_requested_backup(request): and os.environ.get("COULOBRE_LOCAL_ACCOUNT_BACKUP_MAIL") != "1" ): raise ValueError("Enable mailbox backups on the local backup node.") - require_root_directory(BACKUP_DIRECTORY) - directory = os.open( - BACKUP_DIRECTORY, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW - ) - try: - fcntl.flock(directory, fcntl.LOCK_EX) + with locked_root_directory(BACKUP_DIRECTORY): ensure_requested_archive(request) - finally: - os.close(directory) def ensure_requested_archive(request): diff --git a/src/coulobre/account_restore_request.py b/src/coulobre/account_restore_request.py new file mode 100644 index 0000000..cfbde5b --- /dev/null +++ b/src/coulobre/account_restore_request.py @@ -0,0 +1,184 @@ +import errno +import json +import os +from dataclasses import dataclass +from pathlib import Path +from shutil import copyfileobj +from tempfile import TemporaryDirectory +from uuid import UUID +from zipfile import BadZipFile + +from .account_backup import CHUNK_BYTES, open_account_bundle +from .account_backup_request import BACKUP_TIMEOUT_SECONDS, backup_archive +from .node_files import locked_root_directory, read_root_file, write_new_file +from .node_requests import serve_apply_request +from .web_node import WebSite + +REQUEST_VERSION = 1 +RESTORE_DIRECTORY = Path("/var/lib/coulobre/account-restores") +RESTORE_SOCKET = "/run/coulobre-account-restore.sock" +RESTORE_TIMEOUT_SECONDS = BACKUP_TIMEOUT_SECONDS +MAX_RESTORE_PATH_BYTES = 1024 + + +def validate_restore_path(filename): + from .web_node_backup import relative_file_parts + + if not isinstance(filename, str) or not filename.isprintable(): + raise ValueError("Choose a file path relative to the document root.") + parts = relative_file_parts(filename) + if len(filename.encode("utf-8")) > MAX_RESTORE_PATH_BYTES or any( + len(part.encode("utf-8")) > 255 for part in parts + ): + raise ValueError("The restore path is too long.") + + +@dataclass(frozen=True) +class WebsiteRestoreRequest: + restore_id: UUID + backup_id: UUID + site: WebSite + filename: str | None + replace: bool + + def __post_init__(self): + if type(self.replace) is not bool: + raise ValueError("Expected a boolean replacement option.") + if self.filename is not None: + validate_restore_path(self.filename) + elif self.replace: + raise ValueError("Choose a file when replacing live content.") + + @classmethod + def from_manifest(cls, data): + if ( + not isinstance(data, dict) + or data.keys() + != { + "version", + "restore_id", + "backup_id", + "site", + "filename", + "replace", + } + or type(data["version"]) is not int + or data["version"] != REQUEST_VERSION + ): + raise ValueError("Expected a local website restore request.") + return cls( + parse_uuid(data["restore_id"]), + parse_uuid(data["backup_id"]), + WebSite.from_manifest(data["site"]), + data["filename"], + data["replace"], + ) + + def manifest(self): + return { + "version": REQUEST_VERSION, + "restore_id": str(self.restore_id), + "backup_id": str(self.backup_id), + "site": self.site.manifest(), + "filename": self.filename, + "replace": self.replace, + } + + +def parse_uuid(value): + if isinstance(value, str): + try: + identifier = UUID(value) + except ValueError: + pass + else: + if str(identifier) == value: + return identifier + raise ValueError("Expected a canonical restore or backup ID.") + + +def serve_website_restore(): + return serve_apply_request( + REQUEST_VERSION, + WebsiteRestoreRequest.from_manifest, + restore_requested_website, + limit=16 * 1024, + ) + + +def restore_requested_website(request): + if os.geteuid() != 0: + raise ValueError( + "Run restore-website-request as root on the backup node." + ) + with locked_root_directory(RESTORE_DIRECTORY) as directory: + claim = RESTORE_DIRECTORY / f"{request.restore_id}.json" + result = claim.with_suffix(".result") + manifest = json.dumps(request.manifest()) + try: + write_new_file(claim, manifest, mode=0o600) + except FileExistsError: + if read_root_file(claim, mode=0o600) != manifest: + raise ValueError( + "This restore ID belongs to a different request." + ) from None + if not result.exists(): + raise ValueError( + "The previous restore was interrupted. " + "Check the destination before requesting another restore." + ) from None + problem = json.loads(read_root_file(result, mode=0o600)) + else: + # Persist the claim before writing website files. + os.fsync(directory) + problem = None + try: + restore_website_from_bundle(request) + except (OSError, ValueError) as error: + problem = str(error) + write_new_file(result, json.dumps(problem), mode=0o600) + os.fsync(directory) + if problem is not None: + raise ValueError(problem) + + +def restore_website_from_bundle(request): + from .web_node_backup import restore_native_website + + archive = backup_archive(request.site.account_id, request.backup_id) + try: + with ( + open_account_bundle(archive) as (bundle, backup), + TemporaryDirectory(dir=RESTORE_DIRECTORY) as temporary, + ): + if backup.website != request.site: + raise ValueError("This backup is for a different website.") + staged = Path(temporary) / "website.tar.gz" + with ( + bundle.open(staged.name) as source, + staged.open("xb") as target, + ): + os.fchmod(target.fileno(), 0o600) + copyfileobj(source, target, length=CHUNK_BYTES) + restore_native_website( + request.site, + staged, + filename=request.filename, + replace=request.replace, + ) + except FileNotFoundError as error: + if error.filename == str(archive): + raise ValueError( + "The selected backup archive is no longer on disk." + ) from None + raise + except OSError as error: + if error.errno == errno.EDQUOT: + raise ValueError( + "The restore exceeded a filesystem storage quota." + ) from None + raise + except BadZipFile: + raise ValueError( + "The selected account backup ZIP is unreadable." + ) from None diff --git a/src/coulobre/hosting/account_backup_forms.py b/src/coulobre/hosting/account_backup_forms.py index 7a11a9d..f686036 100644 --- a/src/coulobre/hosting/account_backup_forms.py +++ b/src/coulobre/hosting/account_backup_forms.py @@ -1,4 +1,12 @@ +from uuid import uuid4 + from django import forms +from django.core.exceptions import ValidationError + +from coulobre.account_restore_request import ( + MAX_RESTORE_PATH_BYTES, + validate_restore_path, +) from .models import AccountBackupSchedule @@ -58,3 +66,48 @@ class AccountBackupScheduleForm(forms.Form): "or pause the schedule.", ) return cleaned + + +class WebsiteRestoreForm(forms.Form): + restore_id = forms.UUIDField(initial=uuid4, widget=forms.HiddenInput) + scope = forms.ChoiceField( + choices=(("file", "One file"), ("website", "Entire website")), + initial="file", + widget=forms.RadioSelect, + ) + filename = forms.CharField( + label="File path", + max_length=MAX_RESTORE_PATH_BYTES, + required=False, + strip=False, + help_text="Use a path relative to the document root.", + ) + replace = forms.BooleanField( + label="Replace the existing file at this path", required=False + ) + + def clean_filename(self): + filename = self.cleaned_data["filename"] + if filename: + try: + validate_restore_path(filename) + except ValueError as error: + raise ValidationError(str(error)) from error + return filename + + def clean(self): + cleaned = super().clean() + if cleaned.get("scope") == "file" and cleaned.get("filename") == "": + self.add_error( + "filename", "Enter the path of the file to restore." + ) + if cleaned.get("scope") == "website": + if cleaned.get("filename"): + self.add_error( + "filename", "Clear the path to restore the entire website." + ) + if cleaned.get("replace"): + self.add_error( + "replace", "Replacement is only available for one file." + ) + return cleaned diff --git a/src/coulobre/hosting/account_backups.py b/src/coulobre/hosting/account_backups.py index 1ec172d..032df1c 100644 --- a/src/coulobre/hosting/account_backups.py +++ b/src/coulobre/hosting/account_backups.py @@ -1,13 +1,18 @@ from datetime import UTC, datetime, timedelta -from django.core.exceptions import PermissionDenied +from django.core.exceptions import PermissionDenied, ValidationError from django.db import transaction from django.utils import timezone from coulobre.account_backup import AccountBackup from coulobre.web_node import WebSite -from .models import AccountBackupSchedule, HostingAccount, HostingMailbox +from .models import ( + AccountBackupSchedule, + HostingAccount, + HostingMailbox, + WebsiteRestoreJob, +) from .resource_requests import lock_hosting_account @@ -110,3 +115,37 @@ def _queue_scheduled_backup(account_id, now): ) schedule.next_run_at = _next_backup_run(schedule, now) schedule.save(update_fields=["next_run_at"]) + + +@transaction.atomic +def queue_website_restore( + backup, *, restore_id, filename, replace, operator_username +): + account = lock_hosting_account(backup.account_id, customer_id=None) + if not backup.can_restore_website( + WebSite(account.pk, account.primary_domain) + ): + raise ValidationError( + "Choose a completed backup of the current website." + ) + + jobs = WebsiteRestoreJob.objects + details = { + "backup_id": backup.pk, + "filename": filename, + "replace": replace, + "operator_username": operator_username, + } + job = jobs.filter(restore_id=restore_id).first() + if job is None: + if jobs.filter( + backup__account=account, finished_at__isnull=True + ).exists(): + raise ValidationError( + "Wait for the current website restore to finish." + ) + job, _ = jobs.get_or_create(restore_id=restore_id, defaults=details) + if any(getattr(job, field) != value for field, value in details.items()): + raise ValidationError( + "Reopen the restore form to submit a new request." + ) diff --git a/src/coulobre/hosting/migrations/0026_website_restore_jobs.py b/src/coulobre/hosting/migrations/0026_website_restore_jobs.py new file mode 100644 index 0000000..301833f --- /dev/null +++ b/src/coulobre/hosting/migrations/0026_website_restore_jobs.py @@ -0,0 +1,59 @@ +# Generated by Django 5.2.19 on 2026-11-21 13:36 + +import django.db.models.deletion +import django.utils.timezone +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("hosting", "0025_account_backup_schedules"), + ] + + operations = [ + migrations.CreateModel( + name="WebsiteRestoreJob", + fields=[ + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ( + "requested_at", + models.DateTimeField(default=django.utils.timezone.now), + ), + ( + "last_dispatched_at", + models.DateTimeField(blank=True, null=True), + ), + ("started_at", models.DateTimeField(blank=True, null=True)), + ("finished_at", models.DateTimeField(blank=True, null=True)), + ("problem", models.TextField(blank=True)), + ("restore_id", models.UUIDField(editable=False, unique=True)), + ("filename", models.CharField(blank=True, max_length=1024)), + ("replace", models.BooleanField(default=False)), + ("operator_username", models.CharField(max_length=150)), + ( + "backup", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + related_name="website_restores", + to="hosting.accountbackupjob", + ), + ), + ], + options={ + "indexes": [ + models.Index( + fields=["finished_at", "requested_at"], + name="hosting_web_finishe_a9b362_idx", + ) + ], + }, + ), + ] diff --git a/src/coulobre/hosting/models.py b/src/coulobre/hosting/models.py index 26c142f..c236a6b 100644 --- a/src/coulobre/hosting/models.py +++ b/src/coulobre/hosting/models.py @@ -11,6 +11,7 @@ from django.urls import reverse from django.utils import timezone from coulobre.account_backup_request import backup_archive +from coulobre.account_restore_request import MAX_RESTORE_PATH_BYTES from coulobre.database_node import ( DATABASE_SUFFIX_PATTERN, INVALID_SUFFIX, @@ -458,6 +459,27 @@ class AccountBackupJob(ProvisioningJob): def includes_mailboxes(self): return "mailboxes" in self.manifest + def can_restore_website(self, site): + return ( + self.state == "configured" + and self.manifest.get("website") == site.manifest() + ) + + +class WebsiteRestoreJob(ProvisioningJob): + backup = models.ForeignKey( + AccountBackupJob, + on_delete=models.CASCADE, + related_name="website_restores", + ) + restore_id = models.UUIDField(unique=True, editable=False) + filename = models.CharField(max_length=MAX_RESTORE_PATH_BYTES, blank=True) + replace = models.BooleanField(default=False) + operator_username = models.CharField(max_length=150) + + class Meta: + indexes = [models.Index(fields=("finished_at", "requested_at"))] + class AccountBackupSchedule(models.Model): class Frequency(models.TextChoices): diff --git a/src/coulobre/hosting/node_client.py b/src/coulobre/hosting/node_client.py index 492e901..479b699 100644 --- a/src/coulobre/hosting/node_client.py +++ b/src/coulobre/hosting/node_client.py @@ -5,6 +5,10 @@ from coulobre.account_backup_request import ( BACKUP_SOCKET, BACKUP_TIMEOUT_SECONDS, ) +from coulobre.account_restore_request import ( + RESTORE_SOCKET, + RESTORE_TIMEOUT_SECONDS, +) from coulobre.mail_node import MailboxQuotaUpdate from coulobre.web_node import ( MAX_STORAGE_BYTES, @@ -106,6 +110,16 @@ def create_local_account_backup(request): ) +def restore_local_website(request): + apply_on_local_node( + request, + RESTORE_SOCKET, + "backup node", + "website restore", + timeout=RESTORE_TIMEOUT_SECONDS + 15, + ) + + def encode_manifest(manifest): return json.dumps(manifest).encode("utf-8") diff --git a/src/coulobre/hosting/tasks.py b/src/coulobre/hosting/tasks.py index 38c74cf..6486ecb 100644 --- a/src/coulobre/hosting/tasks.py +++ b/src/coulobre/hosting/tasks.py @@ -10,6 +10,10 @@ from coulobre.account_backup_request import ( BACKUP_TIMEOUT_SECONDS, AccountBackupRequest, ) +from coulobre.account_restore_request import ( + RESTORE_TIMEOUT_SECONDS, + WebsiteRestoreRequest, +) from coulobre.dns_node import DnsZone from coulobre.sftp_keys import SFTPKeys from coulobre.web_node import WebSite @@ -26,6 +30,7 @@ from .models import ( WebActivation, WebHTTPS, WebProvisioningPlan, + WebsiteRestoreJob, ) from .node_client import ( activate_local_site, @@ -35,6 +40,7 @@ from .node_client import ( provision_local_database, provision_local_mailbox, publish_local_zone, + restore_local_website, set_local_site_storage_limit, update_local_mailbox_quota, update_local_sftp, @@ -43,6 +49,7 @@ from .sftp import site_is_active REDISPATCH_AFTER = timedelta(minutes=5) ACCOUNT_BACKUP_LEASE = timedelta(seconds=BACKUP_TIMEOUT_SECONDS + 60) +WEBSITE_RESTORE_LEASE = timedelta(seconds=RESTORE_TIMEOUT_SECONDS + 60) ACCOUNT_BACKUP_QUEUE = "coulobre-account-backups" WEB_ACTIVATION_QUEUE = "coulobre-web-activation" WEB_HTTPS_QUEUE = "coulobre-web-https" @@ -160,6 +167,14 @@ def dispatch_account_backups(): lease=ACCOUNT_BACKUP_LEASE, ) + if settings.LOCAL_WEBSITE_RESTORE: + dispatch_provisioning_jobs( + WebsiteRestoreJob, + restore_website, + ACCOUNT_BACKUP_QUEUE, + lease=WEBSITE_RESTORE_LEASE, + ) + def dispatch_provisioning_jobs(model, task, queue, *, lease=REDISPATCH_AFTER): now = timezone.now() @@ -371,6 +386,35 @@ def apply_account_backup(job): create_local_account_backup(AccountBackupRequest(job.backup_id, backup)) +@shared_task(acks_late=True, reject_on_worker_lost=True) +def restore_website(job_id): + if settings.LOCAL_ACCOUNT_BACKUPS and settings.LOCAL_WEBSITE_RESTORE: + run_provisioning_job( + WebsiteRestoreJob.objects.select_related("backup__account"), + job_id, + apply_website_restore, + "Could not confirm the restore on the local backup node. " + "Check the destination before requesting another restore.", + lease=WEBSITE_RESTORE_LEASE, + ) + + +def apply_website_restore(job): + account = job.backup.account + site = WebSite(account.pk, account.primary_domain) + if not job.backup.can_restore_website(site): + raise ValueError("The backup no longer matches the current website.") + restore_local_website( + WebsiteRestoreRequest( + job.restore_id, + job.backup.backup_id, + site, + job.filename or None, + job.replace, + ) + ) + + def run_provisioning_job( jobs, job_id, apply, connection_problem, *, lease=REDISPATCH_AFTER ): diff --git a/src/coulobre/hosting/templates/hosting/account_backups.html b/src/coulobre/hosting/templates/hosting/account_backups.html index 35d4008..ec1f7ab 100644 --- a/src/coulobre/hosting/templates/hosting/account_backups.html +++ b/src/coulobre/hosting/templates/hosting/account_backups.html @@ -62,6 +62,9 @@
{{ job.archive }}
+ {% if job.pk in website_restore_sources %}
+
+ {% endif %}
{% elif job.problem %}
{{ job.problem }}
{% endif %}
@@ -75,3 +78,7 @@
No backups requested.
{% endif %} + +{% if website_restore_jobs %} + {% include "hosting/website_restore_history.html" %} +{% endif %} diff --git a/src/coulobre/hosting/templates/hosting/website_restore.html b/src/coulobre/hosting/templates/hosting/website_restore.html new file mode 100644 index 0000000..d7a0ab0 --- /dev/null +++ b/src/coulobre/hosting/templates/hosting/website_restore.html @@ -0,0 +1,22 @@ +{% extends "hosting/base.html" %} +{% block title %}Restore website · Coulobre Panel{% endblock %} +{% block content %} + ← {{ account.name }} +Restoring the entire website requires an empty document root. For a single file, its parent directory must already exist.
+ +| Requested | Operator | Backup requested | Restore target | Status |
|---|---|---|---|---|
| {{ restore.requested_at|date:"j M Y, H:i" }} UTC | +{{ restore.operator_username }} | +{{ restore.backup.requested_at|date:"j M Y, H:i" }} UTC | +
+ {% if restore.filename %}
+ {{ restore.filename }}
+ {% if restore.replace %}(replacement allowed){% endif %}
+ {% else %}
+ Entire website
+ {% endif %}
+ |
+
+ {% if restore.state == "configured" %}
+ Restored
+ {% else %}
+ {{ restore.state|capfirst }}
+ {% endif %}
+ {% if restore.problem %} {{ restore.problem }} {% endif %}
+ |
+