mirror of
https://github.com/Awuqing/BackupX.git
synced 2026-09-04 15:11:23 +08:00
文件备份新增差异模式:仅打包自上次全量以来的变更并记录删除,恢复自动按全量+差异链还原。含基线解析、链式恢复、保留链保护与本机文件任务校验;清单/比对/删除/往返/保留保护单测全覆盖。
53 lines
2.9 KiB
Go
53 lines
2.9 KiB
Go
package model
|
|
|
|
import "time"
|
|
|
|
const (
|
|
BackupRecordStatusRunning = "running"
|
|
BackupRecordStatusSuccess = "success"
|
|
BackupRecordStatusFailed = "failed"
|
|
)
|
|
|
|
const (
|
|
// BackupKindFull 全量备份;BackupKindDifferential 差异备份(仅含自基线全量以来的变更)。
|
|
BackupKindFull = "full"
|
|
BackupKindDifferential = "differential"
|
|
)
|
|
|
|
type BackupRecord struct {
|
|
ID uint `gorm:"primaryKey" json:"id"`
|
|
TaskID uint `gorm:"column:task_id;index;not null" json:"taskId"`
|
|
Task BackupTask `json:"task,omitempty"`
|
|
StorageTargetID uint `gorm:"column:storage_target_id;index;not null" json:"storageTargetId"`
|
|
StorageTarget StorageTarget `json:"storageTarget,omitempty"`
|
|
// NodeID 执行该次备份的节点(0 = 本机 Master)。用于集群中识别 local_disk 类型
|
|
// 存储的归属节点,避免 Master 端试图跨节点访问远程 Agent 的本地存储。
|
|
NodeID uint `gorm:"column:node_id;index;default:0" json:"nodeId"`
|
|
Status string `gorm:"size:20;index;not null" json:"status"`
|
|
FileName string `gorm:"column:file_name;size:255" json:"fileName"`
|
|
FileSize int64 `gorm:"column:file_size;not null;default:0" json:"fileSize"`
|
|
Checksum string `gorm:"column:checksum;size:64" json:"checksum"`
|
|
StoragePath string `gorm:"column:storage_path;size:500" json:"storagePath"`
|
|
StorageUploadResults string `gorm:"column:storage_upload_results;type:text" json:"-"`
|
|
DurationSeconds int `gorm:"column:duration_seconds;not null;default:0" json:"durationSeconds"`
|
|
// Locked 保留锁定(法律保留):为 true 时该备份不参与保留期/数量自动清理,
|
|
// 且禁止手动删除,直到显式解锁。用于保护合规快照、迁移前基线等关键备份。
|
|
Locked bool `gorm:"column:locked;not null;default:false;index" json:"locked"`
|
|
// BackupKind 备份类型:full(全量)/ differential(差异)。
|
|
BackupKind string `gorm:"column:backup_kind;size:16;not null;default:'full';index" json:"backupKind"`
|
|
// BaseRecordID 差异备份所基于的全量备份记录 ID(全量记录为 0)。
|
|
BaseRecordID uint `gorm:"column:base_record_id;index;not null;default:0" json:"baseRecordId"`
|
|
// Manifest 全量备份的条目清单(JSON),供后续差异备份比对;差异记录为空。
|
|
Manifest string `gorm:"column:manifest;type:text" json:"-"`
|
|
ErrorMessage string `gorm:"column:error_message;size:2000" json:"errorMessage"`
|
|
LogContent string `gorm:"column:log_content;type:text" json:"logContent"`
|
|
StartedAt time.Time `gorm:"column:started_at;index;not null" json:"startedAt"`
|
|
CompletedAt *time.Time `gorm:"column:completed_at;index" json:"completedAt,omitempty"`
|
|
CreatedAt time.Time `json:"createdAt"`
|
|
UpdatedAt time.Time `json:"updatedAt"`
|
|
}
|
|
|
|
func (BackupRecord) TableName() string {
|
|
return "backup_records"
|
|
}
|