[Feature] 数据库备份与恢复:一键导出/导入保障数据安全
Open
Nobody has claimed this yet.
enhancement
status: pending-review
- Dominant language
- Python
- Stars
- 739
- Forks
- 97
- Avg merge
- 10h 3m
- Merged PRs (30d)
- 82
Description
背景与目标
TrailSnap 是自托管应用,数据安全是用户最核心的诉求。当前设置页有配置 JSON 的导入/导出,但缺乏数据库和照片元数据的备份/恢复机制。一旦数据库损坏,所有 AI 分析结果、人脸聚类、标签分类将全部丢失。
功能范围
- 一键导出 PostgreSQL 数据库为 SQL 文件(
pg_dump) - 一键从 SQL 文件恢复数据库
- 定时自动备份(可配置周期和保留份数)
- 备份文件列表管理(查看、下载、删除)
- 备份状态和进度通知
技术方案
- 后端:新增
GET /api/system/backup、POST /api/system/backup、POST /api/system/backup/restore端点 - 通过
subprocess调用pg_dump/psql,输出到data/backups/目录 - 定时任务复用现有
TaskManager._scheduler_loop机制 - 前端:设置页新增"备份与恢复"标签页
优先级
高 — 自托管应用的数据安全是基本需求,缺少备份是用户上车的最大顾虑
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the proposed /api/system/backup and /api/system/backup/restore endpoints, the existing settings-page configuration import/export, and TaskManager._scheduler_loop. Trace how pg_dump and psql can use data/backups/. Done means scheduled and manual backups, restore, backup listing/download/deletion, configurable retention, progress status, and the new settings tab are all covered.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- postgresql, python
- Domain
- api, backend, database, frontend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100