mirror of
https://github.com/Awuqing/BackupX.git
synced 2026-06-12 21:29:35 +08:00
* feat(restore): 支持恢复到指定目录(文件类型本机恢复)
恢复此前只能覆盖原始源路径。新增「恢复到指定目录」:把文件备份还原到任意目录,
用于测试恢复、迁移、并排恢复而不覆盖现网数据。
- backup.TaskSpec +RestoreTargetPath;FileRunner.Restore 非空时把归档解压到该目录。
- model.RestoreRecord +TargetPath(持久化/审计)。
- RestoreService.Start 增加 targetPath 参数与校验:仅文件类型、需绝对路径、
远程节点暂不支持(清晰报错);executeLocally 透传到 spec。
- 恢复触发端点接受可选请求体 {targetPath}(无 body 时恢复到原始路径)。
- 测试:恢复到指定目录后文件落在该目录;相对路径被拒。
* feat(restore): 恢复确认弹窗支持指定恢复目录
文件类型 + 本机恢复时,恢复确认弹窗新增「恢复到指定目录」输入(可选、绝对路径、
留空=原位置),并实时反映在「恢复目标」摘要中;经 startRestoreFromBackup 透传 targetPath。
36 lines
1.7 KiB
Go
36 lines
1.7 KiB
Go
package model
|
||
|
||
import "time"
|
||
|
||
// RestoreRecord 代表一次恢复执行,用于审计、实时日志与列表页。
|
||
// 每次从 BackupRecord 触发恢复都会产生独立 RestoreRecord,与 BackupRecord 一对多。
|
||
const (
|
||
RestoreRecordStatusRunning = "running"
|
||
RestoreRecordStatusSuccess = "success"
|
||
RestoreRecordStatusFailed = "failed"
|
||
)
|
||
|
||
type RestoreRecord struct {
|
||
ID uint `gorm:"primaryKey" json:"id"`
|
||
BackupRecordID uint `gorm:"column:backup_record_id;index;not null" json:"backupRecordId"`
|
||
BackupRecord BackupRecord `json:"backupRecord,omitempty"`
|
||
TaskID uint `gorm:"column:task_id;index;not null" json:"taskId"`
|
||
Task BackupTask `json:"task,omitempty"`
|
||
NodeID uint `gorm:"column:node_id;index;default:0" json:"nodeId"`
|
||
// TargetPath 恢复到指定目录(仅文件类型本机恢复);空 = 恢复到原始源路径。
|
||
TargetPath string `gorm:"column:target_path;size:500" json:"targetPath"`
|
||
Status string `gorm:"size:20;index;not null" json:"status"`
|
||
ErrorMessage string `gorm:"column:error_message;size:2000" json:"errorMessage"`
|
||
LogContent string `gorm:"column:log_content;type:text" json:"logContent"`
|
||
DurationSeconds int `gorm:"column:duration_seconds;not null;default:0" json:"durationSeconds"`
|
||
StartedAt time.Time `gorm:"column:started_at;index;not null" json:"startedAt"`
|
||
CompletedAt *time.Time `gorm:"column:completed_at;index" json:"completedAt,omitempty"`
|
||
TriggeredBy string `gorm:"column:triggered_by;size:100" json:"triggeredBy"`
|
||
CreatedAt time.Time `json:"createdAt"`
|
||
UpdatedAt time.Time `json:"updatedAt"`
|
||
}
|
||
|
||
func (RestoreRecord) TableName() string {
|
||
return "restore_records"
|
||
}
|