diff --git a/builder/exector/groupapp_restore.go b/builder/exector/groupapp_restore.go index 497c8d5f2..b5abbd759 100644 --- a/builder/exector/groupapp_restore.go +++ b/builder/exector/groupapp_restore.go @@ -197,15 +197,16 @@ func (b *BackupAPPRestore) restoreVersionAndData(backup *dbmodel.AppBackup, appS logrus.Errorf("restore statefulset service(%s) volume(%s) data error.%s", app.ServiceID, volume.VolumeName, err.Error()) return err } - for _, podName := range list { - newNameTmp := strings.Split(podName, "-") + for _, path := range list { + newNameTmp := strings.Split(filepath.Base(path), "-") newNameTmp[0] = b.serviceChange[b.getOldServiceID(app.ServiceID)].ServiceAlias newName := strings.Join(newNameTmp, "-") - err := util.Rename(filepath.Join(tmpDir, podName), filepath.Join(tmpDir, newName)) + newpath := filepath.Join(util.GetParentDirectory(path), newName) + err := util.Rename(path, newpath) if err != nil { return err } - if err := os.Chmod(filepath.Join(tmpDir, newName), 0777); err != nil { + if err := os.Chmod(newpath, 0777); err != nil { return err } } diff --git a/util/comman.go b/util/comman.go index 01043480d..f5d93f0a6 100644 --- a/util/comman.go +++ b/util/comman.go @@ -530,7 +530,7 @@ func GetDirList(dirpath string, level int) ([]string, error) { for _, f := range list { if f.IsDir() { if level <= 1 { - dirlist = append(dirlist, f.Name()) + dirlist = append(dirlist, filepath.Join(dirpath, f.Name())) } else { list, err := GetDirList(filepath.Join(dirpath, f.Name()), level-1) if err != nil {