feat: Business Central backup Docker container with web management panel
Python backup module (Azure AD OAuth2 → BC API v2.0 → GPG AES256 → S3), Flask web UI on port 1890 with SSE live log streaming, dual incremental + full backup schedules, chain restore merging full + incrementals, and per-entity file browser with ZIP download. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
165
templates/restore_view.html
Normal file
165
templates/restore_view.html
Normal file
@@ -0,0 +1,165 @@
|
||||
{% extends "base.html" %}
|
||||
{% block title %} — Restore #{{ restore['id'] }}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="page-header">
|
||||
<div>
|
||||
<h4 class="mb-0">
|
||||
<i class="bi bi-folder2-open me-2 text-warning"></i>Restore #{{ restore['id'] }}
|
||||
</h4>
|
||||
<div class="text-muted small mt-1">
|
||||
{{ restore['s3_key'].split('/')[-1] }} ·
|
||||
Started {{ restore['started_at'] | fmtdt }} ·
|
||||
{{ restore['started_at'] | duration(restore['completed_at']) }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="d-flex gap-2">
|
||||
{% if restore['status'] == 'success' %}
|
||||
<a href="{{ url_for('restore_download_zip', restore_id=restore['id']) }}"
|
||||
class="btn btn-outline-primary">
|
||||
<i class="bi bi-file-zip me-1"></i>Download All (ZIP)
|
||||
</a>
|
||||
{% endif %}
|
||||
<a href="{{ url_for('restore_list') }}" class="btn btn-outline-secondary">
|
||||
<i class="bi bi-arrow-left me-1"></i>All Restores
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if streaming_id %}
|
||||
<!-- Still running — show live log -->
|
||||
<div class="card stat-card mb-3">
|
||||
<div class="card-body">
|
||||
<div class="d-flex align-items-center gap-2 mb-3">
|
||||
<div class="spinner-border spinner-border-sm text-warning"></div>
|
||||
<span id="liveStatus" class="text-muted">Restore in progress…</span>
|
||||
</div>
|
||||
<div class="log-terminal" id="liveLog"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% elif restore['status'] == 'failed' %}
|
||||
<div class="alert alert-danger border-0 shadow-sm">
|
||||
<i class="bi bi-x-circle-fill me-2"></i>
|
||||
<strong>Restore failed:</strong> {{ restore['error_message'] or 'Unknown error' }}
|
||||
</div>
|
||||
|
||||
{% else %}
|
||||
<!-- Success — restore type banner -->
|
||||
{% set rmode = restore_info.get('restore_mode', 'full') %}
|
||||
{% if rmode == 'chain' %}
|
||||
<div class="alert alert-success border-0 shadow-sm mb-4">
|
||||
<i class="bi bi-check-circle-fill me-2"></i>
|
||||
<strong>Chain Restore</strong> — {{ restore_info.get('chain_length', 1) }} archives merged
|
||||
(1 full + {{ restore_info.get('chain_length', 1) - 1 }} incremental).
|
||||
<span class="ms-2 text-success fw-semibold">{{ restore['file_count'] }} entity files — complete snapshot.</span>
|
||||
</div>
|
||||
{% elif rmode == 'incremental' %}
|
||||
<div class="alert alert-warning border-0 shadow-sm mb-4">
|
||||
<i class="bi bi-exclamation-triangle-fill me-2"></i>
|
||||
<strong>Partial Restore</strong> — this is a single incremental archive.
|
||||
Only <strong>{{ restore['file_count'] }} entity files</strong> with changes in that specific run are present.
|
||||
<span class="ms-2">Use <strong>Chain Restore</strong> from the Restore page for a complete snapshot.</span>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="alert alert-success border-0 shadow-sm mb-4">
|
||||
<i class="bi bi-check-circle-fill me-2"></i>
|
||||
<strong>Full Snapshot</strong> — <strong>{{ restore['file_count'] }} entity files</strong> extracted.
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if by_company %}
|
||||
<!-- Search box -->
|
||||
<div class="mb-3">
|
||||
<input type="text" id="entitySearch" class="form-control"
|
||||
placeholder="Filter entities… (e.g. customers, salesInvoices)">
|
||||
</div>
|
||||
|
||||
<div class="accordion" id="companyAccordion">
|
||||
{% for company in by_company | sort %}
|
||||
{% set entities = by_company[company] %}
|
||||
<div class="accordion-item border-0 mb-2 shadow-sm rounded overflow-hidden">
|
||||
<h2 class="accordion-header">
|
||||
<button class="accordion-button fw-semibold" type="button"
|
||||
data-bs-toggle="collapse"
|
||||
data-bs-target="#collapse-{{ loop.index }}"
|
||||
aria-expanded="true">
|
||||
<i class="bi bi-building me-2 text-primary"></i>
|
||||
{{ company }}
|
||||
<span class="badge bg-primary bg-opacity-15 text-primary ms-2">
|
||||
{{ entities | length }} entities
|
||||
</span>
|
||||
</button>
|
||||
</h2>
|
||||
<div id="collapse-{{ loop.index }}" class="accordion-collapse collapse show">
|
||||
<div class="accordion-body p-0">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover table-sm mb-0 table-files">
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th>Entity</th>
|
||||
<th>Format</th>
|
||||
<th>Size</th>
|
||||
<th class="text-end"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for f in entities %}
|
||||
<tr data-entity="{{ f['entity'] }}">
|
||||
<td class="font-monospace">{{ f['entity'] }}</td>
|
||||
<td><span class="badge bg-secondary bg-opacity-15 text-secondary">{{ f['ext'] }}</span></td>
|
||||
<td class="text-muted small">{{ f['size_kb'] }} KB</td>
|
||||
<td class="text-end">
|
||||
<a href="{{ url_for('restore_download_file', restore_id=restore['id']) }}?path={{ f['path'] | urlencode }}"
|
||||
class="btn btn-outline-secondary btn-sm py-0">
|
||||
<i class="bi bi-download me-1"></i>Download
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="text-muted text-center py-4">No entity files found in this restore.</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block scripts %}
|
||||
{% if streaming_id %}
|
||||
<script>
|
||||
const liveLog = document.getElementById('liveLog');
|
||||
const liveStatus = document.getElementById('liveStatus');
|
||||
|
||||
const evtSrc = new EventSource('/api/restore/{{ streaming_id }}/stream');
|
||||
evtSrc.onmessage = function(e) {
|
||||
const msg = JSON.parse(e.data);
|
||||
if (msg.keepalive) return;
|
||||
if (msg.done) {
|
||||
evtSrc.close();
|
||||
liveStatus.textContent = msg.status === 'success' ? 'Restore complete — reloading…' : 'Restore failed.';
|
||||
if (msg.status === 'success') setTimeout(() => location.reload(), 1500);
|
||||
return;
|
||||
}
|
||||
if (msg.log) appendLog(liveLog, msg.log);
|
||||
};
|
||||
</script>
|
||||
{% endif %}
|
||||
|
||||
{% if by_company %}
|
||||
<script>
|
||||
document.getElementById('entitySearch').addEventListener('input', function() {
|
||||
const q = this.value.toLowerCase();
|
||||
document.querySelectorAll('.table-files tbody tr').forEach(row => {
|
||||
row.style.display = row.dataset.entity.toLowerCase().includes(q) ? '' : 'none';
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user