package model import "time" // BackupPolicy 备份策略 type BackupPolicy struct { ID uint64 `json:"id" gorm:"primaryKey;autoIncrement"` 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 TargetConfig string `json:"target_config" gorm:"type:json"` // 目标配置JSON 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 { ID uint64 `json:"id" gorm:"primaryKey;autoIncrement"` 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" }