feat: 数据备份管理系统 v0.1.0

带 Web 操作界面的备份系统,支持:
- 数据源:MySQL 数据库(mysqldump)、服务器目录(tar.gz)
- 存储目标:本地目录、S3 兼容对象存储(MinIO/Ceph/AWS S3)
- 触发方式:手动 + Cron 定时调度(APScheduler)
- 备份还原:MySQL 库、目录
- JWT 登录认证 + Fernet 字段加密
- 保留策略:按数量 + 按天数双重清理

技术栈:FastAPI + SQLAlchemy 2 + APScheduler + aioboto3;
前端 Vite + React 18 + TypeScript + Ant Design 5 + Zustand。
Docker Compose 一键起。

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
publ
2026-06-22 18:27:41 +08:00
commit 4e3a4b4602
92 changed files with 5290 additions and 0 deletions
+39
View File
@@ -0,0 +1,39 @@
from datetime import datetime
from sqlalchemy import Boolean, DateTime, ForeignKey, Integer, String, Text, func
from sqlalchemy.orm import Mapped, mapped_column, relationship
from app.database import Base
class Job(Base):
"""备份任务定义。
source_config_json 是 Fernet 加密的 JSON
- mysql: {"host", "port", "user", "password", "database"}
- directory: {"path", "exclude_patterns": [...]}
"""
__tablename__ = "jobs"
id: Mapped[int] = mapped_column(Integer, primary_key=True)
name: Mapped[str] = mapped_column(String(64), unique=True, nullable=False)
type: Mapped[str] = mapped_column(String(16), nullable=False) # 'mysql' / 'directory'
source_config_json: Mapped[str] = mapped_column(Text, nullable=False)
storage_id: Mapped[int] = mapped_column(
Integer, ForeignKey("storages.id", ondelete="RESTRICT"), nullable=False
)
cron_expression: Mapped[str | None] = mapped_column(String(64), nullable=True)
enabled: Mapped[bool] = mapped_column(Boolean, nullable=False, default=True)
retention_count: Mapped[int] = mapped_column(Integer, nullable=False, default=7)
retention_days: Mapped[int | None] = mapped_column(Integer, nullable=True)
description: Mapped[str | None] = mapped_column(String(255), nullable=True)
storage: Mapped["Storage"] = relationship(lazy="joined") # noqa: F821
created_at: Mapped[datetime] = mapped_column(
DateTime, server_default=func.now(), nullable=False
)
updated_at: Mapped[datetime] = mapped_column(
DateTime, server_default=func.now(), onupdate=func.now(), nullable=False
)