Add admin database backup export and import

This commit is contained in:
orohi
2026-07-25 01:22:30 +03:00
parent 7842ddf1b8
commit 06599e58f1
4 changed files with 269 additions and 3 deletions
+23
View File
@@ -30,7 +30,30 @@
<div class="flash">Ссылка удалена</div>
{% elif flash == "toggled" %}
<div class="flash">Статус ссылки обновлён</div>
{% elif flash == "imported" %}
<div class="flash">База восстановлена из бэкапа</div>
{% endif %}
{% if flash_error %}
<div class="alert-error">Импорт не удался: {{ flash_error }}</div>
{% endif %}
<section class="backup-box">
<h2 style="font-family:var(--font-display);font-size:1.15rem;margin:0 0 0.5rem;">Бэкап базы</h2>
<p class="muted" style="margin:0 0 1rem;font-size:0.9rem;">
Экспорт / импорт всех ссылок, активаций и временного трафика (JSON).
Импорт <strong>полностью заменяет</strong> текущие данные.
</p>
<div class="row-actions">
<a class="btn btn-signal" href="/admin/backup/export">Скачать бэкап</a>
</div>
<form class="backup-import" method="post" action="/admin/backup/import" enctype="multipart/form-data" onsubmit="return confirm('Импорт заменит ВСЕ текущие ссылки и историю. Продолжить?')">
<label>
Восстановить из файла
<input type="file" name="file" accept=".json,application/json" required />
</label>
<button class="btn btn-ghost" type="submit">Импортировать</button>
</form>
</section>
<h2 style="font-family:var(--font-display);font-size:1.25rem;margin:0 0 1rem;">Создать ссылку</h2>
<form class="form-grid" method="post" action="/admin/links">