4e3a4b4602
带 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>
51 lines
1.3 KiB
Python
51 lines
1.3 KiB
Python
from datetime import datetime
|
|
from typing import Literal, Optional
|
|
|
|
from pydantic import BaseModel, ConfigDict, Field
|
|
|
|
|
|
class LocalStorageConfig(BaseModel):
|
|
path: str = Field(..., min_length=1, description="本地存储根目录绝对路径")
|
|
|
|
|
|
class S3StorageConfig(BaseModel):
|
|
endpoint_url: Optional[str] = Field(None, description="MinIO/Ceph 自定义 endpoint,留空使用 AWS")
|
|
region: str = Field("us-east-1")
|
|
bucket: str = Field(..., min_length=1)
|
|
access_key: str = Field(..., min_length=1)
|
|
secret_key: str = Field(..., min_length=1)
|
|
use_ssl: bool = True
|
|
path_prefix: str = Field("", description="对象 key 前缀,可空")
|
|
addressing_style: Literal["auto", "path", "virtual"] = "auto"
|
|
|
|
|
|
class StorageBase(BaseModel):
|
|
name: str = Field(..., min_length=1, max_length=64)
|
|
type: Literal["local", "s3"]
|
|
is_default: bool = False
|
|
|
|
|
|
class StorageCreate(StorageBase):
|
|
config: dict
|
|
|
|
|
|
class StorageUpdate(BaseModel):
|
|
name: Optional[str] = Field(None, min_length=1, max_length=64)
|
|
is_default: Optional[bool] = None
|
|
config: Optional[dict] = None
|
|
|
|
|
|
class StorageOut(BaseModel):
|
|
model_config = ConfigDict(from_attributes=True)
|
|
id: int
|
|
name: str
|
|
type: str
|
|
is_default: bool
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
|
|
class StorageTestResponse(BaseModel):
|
|
ok: bool
|
|
message: str
|