[REV] update code for restore volume

This commit is contained in:
barnettZQG 2018-05-30 15:59:34 +08:00
parent 64f46bf9a5
commit 3611c1c991
2 changed files with 6 additions and 5 deletions

View File

@ -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
}
}

View File

@ -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 {