diff --git a/agent/app/dto/snapshot.go b/agent/app/dto/snapshot.go index fd19b1126..9a12b0935 100644 --- a/agent/app/dto/snapshot.go +++ b/agent/app/dto/snapshot.go @@ -18,6 +18,7 @@ type SnapshotCreate struct { Description string `json:"description" validate:"max=256"` Secret string `json:"secret"` InterruptStep string `json:"interruptStep"` + Timeout uint `json:"timeout"` AppData []DataTree `json:"appData"` BackupData []DataTree `json:"backupData"` diff --git a/agent/app/model/snapshot.go b/agent/app/model/snapshot.go index 8a4801c9c..eeb28b039 100644 --- a/agent/app/model/snapshot.go +++ b/agent/app/model/snapshot.go @@ -10,6 +10,7 @@ type Snapshot struct { Status string `json:"status"` Message string `json:"message"` Version string `json:"version"` + Timeout uint `json:"timeout"` TaskID string `json:"taskID"` TaskRecoverID string `json:"taskRecoverID"` diff --git a/agent/app/service/snapshot_create.go b/agent/app/service/snapshot_create.go index c3de8d633..a59ff556f 100644 --- a/agent/app/service/snapshot_create.go +++ b/agent/app/service/snapshot_create.go @@ -61,6 +61,7 @@ func (u *SnapshotService) SnapshotCreate(parentTask *task.Task, req dto.Snapshot Version: versionItem.Value, Status: constant.StatusWaiting, + Timeout: req.Timeout, } if err := snapshotRepo.Create(&snap); err != nil { global.LOG.Errorf("create snapshot record to db failed, err: %v", err) @@ -79,7 +80,7 @@ func (u *SnapshotService) SnapshotCreate(parentTask *task.Task, req dto.Snapshot } if jobID == 0 { go func() { - _ = handleSnapshot(req, taskItem, jobID, 3, 0) + _ = handleSnapshot(req, taskItem, jobID, 3, snap.Timeout) }() return nil } @@ -128,10 +129,6 @@ func handleSnapshot(req dto.SnapshotCreate, taskItem *task.Task, jobID, retry, t itemHelper := snapHelper{SnapID: req.ID, Task: *taskItem, FileOp: files.NewFileOp(), Ctx: context.Background(), OpenrestyDir: openrestyDir} baseDir := path.Join(rootDir, "base") _ = os.MkdirAll(baseDir, os.ModePerm) - - if timeout == 0 { - timeout = 1800 - } taskItem.AddSubTaskWithAliasAndOps( "SnapDBInfo", func(t *task.Task) error { diff --git a/agent/app/service/snapshot_recover.go b/agent/app/service/snapshot_recover.go index 112c41242..e18a108e1 100644 --- a/agent/app/service/snapshot_recover.go +++ b/agent/app/service/snapshot_recover.go @@ -175,6 +175,7 @@ func (u *SnapshotService) SnapshotRecover(req dto.SnapshotRecover) error { itemHelper.Task.Log("---------------------- 9 / 11 ----------------------") itemHelper.Task.LogStart(i18n.GetWithName("RecoverWebsite", snap.Name)) webFile := path.Join(rootDir, snap.Name, "/website.tar.gz") + _ = itemHelper.FileOp.CreateDir(snapJson.OperestyDir, os.ModePerm) var err error if itemHelper.FileOp.Stat(webFile) { err = itemHelper.FileOp.TarGzExtractPro(webFile, snapJson.OperestyDir, "") diff --git a/agent/init/migration/migrations/init.go b/agent/init/migration/migrations/init.go index 4dc0abc41..db31b4dbe 100644 --- a/agent/init/migration/migrations/init.go +++ b/agent/init/migration/migrations/init.go @@ -337,7 +337,7 @@ var UpdatePHPRuntime = &gormigrate.Migration{ }, } var AddSnapshotIgnore = &gormigrate.Migration{ - ID: "20250628-add-snapshot-ignore", + ID: "20250716-add-snapshot-ignore", Migrate: func(tx *gorm.DB) error { return tx.AutoMigrate( &model.Snapshot{}, diff --git a/frontend/src/api/interface/setting.ts b/frontend/src/api/interface/setting.ts index ea760ca51..e3e7f597f 100644 --- a/frontend/src/api/interface/setting.ts +++ b/frontend/src/api/interface/setting.ts @@ -1,5 +1,4 @@ import { DateTimeFormats } from '@intlify/core-base'; -import { b } from 'vite/dist/node/types.d-aGj9QkWt'; export namespace Setting { export interface SettingInfo { @@ -135,6 +134,7 @@ export namespace Setting { downloadAccountID: string; description: string; secret: string; + timeout: number; appData: Array; panelData: Array; @@ -167,6 +167,7 @@ export namespace Setting { createdAt: DateTimeFormats; version: string; secret: string; + timeout: number; taskID: string; taskRecoverID: string; diff --git a/frontend/src/views/setting/snapshot/create/index.vue b/frontend/src/views/setting/snapshot/create/index.vue index 1c46a0fe6..98e149ffd 100644 --- a/frontend/src/views/setting/snapshot/create/index.vue +++ b/frontend/src/views/setting/snapshot/create/index.vue @@ -45,6 +45,17 @@ + + + + + @@ -164,7 +175,7 @@