mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-12-11 21:06:08 +08:00
fix: Fix partial abnormal issues caused by local backup path modification
This commit is contained in:
parent
4ac490c6b4
commit
6440b473d5
1 changed files with 43 additions and 2 deletions
|
|
@ -413,9 +413,9 @@ func (u *BackupService) Update(req dto.BackupOperate) error {
|
|||
if strings.HasSuffix(dirStr, "/") && dirStr != "/" {
|
||||
dirStr = dirStr[:strings.LastIndex(dirStr, "/")]
|
||||
}
|
||||
if err := copyDir(oldDir, dirStr); err != nil {
|
||||
if err := changeLocalBackup(oldDir, dirStr); err != nil {
|
||||
_ = backupRepo.Update(req.ID, map[string]interface{}{"vars": oldVars})
|
||||
return err
|
||||
return fmt.Errorf("copy dir from %s to %s failed, err: %v", oldDir, dirStr, err)
|
||||
}
|
||||
global.CONF.System.Backup = dirStr
|
||||
}
|
||||
|
|
@ -677,3 +677,44 @@ func (u *BackupService) Run() {
|
|||
}).Error
|
||||
global.LOG.Info("Successfully refreshed OneDrive token.")
|
||||
}
|
||||
|
||||
func changeLocalBackup(oldPath, newPath string) error {
|
||||
fileOp := fileUtils.NewFileOp()
|
||||
if fileOp.Stat(path.Join(oldPath, "app")) {
|
||||
if err := fileOp.CopyDir(path.Join(oldPath, "app"), newPath); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if fileOp.Stat(path.Join(oldPath, "database")) {
|
||||
if err := fileOp.CopyDir(path.Join(oldPath, "database"), newPath); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if fileOp.Stat(path.Join(oldPath, "directory")) {
|
||||
if err := fileOp.CopyDir(path.Join(oldPath, "directory"), newPath); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if fileOp.Stat(path.Join(oldPath, "system_snapshot")) {
|
||||
if err := fileOp.CopyDir(path.Join(oldPath, "system_snapshot"), newPath); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if fileOp.Stat(path.Join(oldPath, "website")) {
|
||||
if err := fileOp.CopyDir(path.Join(oldPath, "website"), newPath); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if fileOp.Stat(path.Join(oldPath, "log")) {
|
||||
if err := fileOp.CopyDir(path.Join(oldPath, "log"), newPath); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
_ = fileOp.RmRf(path.Join(oldPath, "app"))
|
||||
_ = fileOp.RmRf(path.Join(oldPath, "database"))
|
||||
_ = fileOp.RmRf(path.Join(oldPath, "directory"))
|
||||
_ = fileOp.RmRf(path.Join(oldPath, "system_snapshot"))
|
||||
_ = fileOp.RmRf(path.Join(oldPath, "website"))
|
||||
_ = fileOp.RmRf(path.Join(oldPath, "log"))
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue