MCPcopy Create free account
hub / github.com/1Panel-dev/1Panel / handleAppBackup

Function handleAppBackup

agent/app/service/backup_app.go:125–153  ·  view source on GitHub ↗
(install *model.AppInstall, parentTask *task.Task, recordID uint, backupDir, fileName, excludes, secret, taskID string)

Source from the content-addressed store, hash-verified

123}
124
125func handleAppBackup(install *model.AppInstall, parentTask *task.Task, recordID uint, backupDir, fileName, excludes, secret, taskID string) error {
126 var (
127 err error
128 backupTask *task.Task
129 )
130 backupTask = parentTask
131 if parentTask == nil {
132 backupTask, err = task.NewTaskWithOps(install.Name, task.TaskBackup, task.TaskScopeBackup, taskID, install.ID)
133 if err != nil {
134 return err
135 }
136 }
137
138 itemHandler := func() error { return doAppBackup(install, backupTask, backupDir, fileName, excludes, secret) }
139 if parentTask != nil {
140 return itemHandler()
141 }
142
143 backupTask.AddSubTaskWithOps(task.GetTaskName(install.Name, task.TaskBackup, task.TaskScopeBackup), func(t *task.Task) error { return itemHandler() }, nil, 3, time.Hour)
144 go func() {
145 if err := backupTask.Execute(); err != nil {
146 backupRepo.UpdateRecordByMap(recordID, map[string]interface{}{"status": constant.StatusFailed, "message": err.Error()})
147 return
148 }
149 backupRepo.UpdateRecordByMap(recordID, map[string]interface{}{"status": constant.StatusSuccess})
150 }()
151
152 return nil
153}
154
155func handleAppRecover(install *model.AppInstall, parentTask *task.Task, recoverFile string, isRollback bool, secret, taskID string) error {
156 var (

Callers 3

doWebsiteBackupFunction · 0.85
AppBackupMethod · 0.85
handleAppRecoverFunction · 0.85

Calls 5

doAppBackupFunction · 0.85
UpdateRecordByMapMethod · 0.65
AddSubTaskWithOpsMethod · 0.45
ExecuteMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected