Files

47 lines
2.4 KiB
Go
Raw Permalink Normal View History

2026-07-03 16:01:08 +08:00
package model
import "time"
// BackupPolicy 备份策略
type BackupPolicy struct {
2026-07-18 10:52:32 +08:00
ID uint64 `json:"id" gorm:"primaryKey"`
2026-07-03 16:01:08 +08:00
Name string `json:"name" gorm:"size:128;not null"` // 策略名称
BackupType string `json:"backup_type" gorm:"size:32;not null"` // full=全量, incremental=增量
TargetType string `json:"target_type" gorm:"size:32;not null"` // local=本地, minio=MinIO
2026-07-18 10:52:32 +08:00
TargetConfig string `json:"target_config" gorm:"type:text"` // 目标配置JSON
2026-07-03 16:01:08 +08:00
IncludeDB int8 `json:"include_db" gorm:"default:1"` // 是否备份数据库
IncludeFiles int8 `json:"include_files" gorm:"default:1"` // 是否备份文件
CronExpr string `json:"cron_expr" gorm:"size:64"` // cron表达式
MaxBackups int `json:"max_backups" gorm:"default:7"` // 最大保留数
Status int8 `json:"status" gorm:"default:1"` // 1=启用 0=禁用
LastRunAt *time.Time `json:"last_run_at"` // 上次执行时间
NextRunAt *time.Time `json:"next_run_at"` // 下次执行时间
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
func (BackupPolicy) TableName() string {
return "fs_backup_policy"
}
// BackupLog 备份执行日志
type BackupLog struct {
2026-07-18 10:52:32 +08:00
ID uint64 `json:"id" gorm:"primaryKey"`
2026-07-03 16:01:08 +08:00
PolicyID uint64 `json:"policy_id" gorm:"index;not null"`
PolicyName string `json:"policy_name" gorm:"size:128"`
BackupType string `json:"backup_type" gorm:"size:32"`
Status string `json:"status" gorm:"size:32;default:running"` // running/success/failed
FilePath string `json:"file_path" gorm:"size:512"` // 备份文件路径
FileSize int64 `json:"file_size"` // 备份文件大小
DBSize int64 `json:"db_size"` // 数据库备份大小
FilesCount int `json:"files_count"` // 备份文件数量
Duration int `json:"duration"` // 耗时(秒)
ErrorMsg string `json:"error_msg" gorm:"size:512"` // 错误信息
StartedAt time.Time `json:"started_at"`
FinishedAt *time.Time `json:"finished_at"`
}
func (BackupLog) TableName() string {
return "fs_backup_log"
}