|
|
@ -6,7 +6,6 @@ import (
|
|
|
|
"fmt"
|
|
|
|
"fmt"
|
|
|
|
"io/ioutil"
|
|
|
|
"io/ioutil"
|
|
|
|
"os"
|
|
|
|
"os"
|
|
|
|
"os/exec"
|
|
|
|
|
|
|
|
"path/filepath"
|
|
|
|
"path/filepath"
|
|
|
|
"strings"
|
|
|
|
"strings"
|
|
|
|
"time"
|
|
|
|
"time"
|
|
|
@ -614,10 +613,10 @@ func (u *SnapshotService) handlePanelDatas(fileOp files.FileOp, operation string
|
|
|
|
case "recover":
|
|
|
|
case "recover":
|
|
|
|
exclusionRules := ""
|
|
|
|
exclusionRules := ""
|
|
|
|
if strings.Contains(backupDir, target) {
|
|
|
|
if strings.Contains(backupDir, target) {
|
|
|
|
exclusionRules += ("1Panel" + strings.ReplaceAll(backupDir, target, "") + ";")
|
|
|
|
exclusionRules += ("1panel" + strings.ReplaceAll(backupDir, target, "") + ";")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if strings.Contains(dockerDir, target) {
|
|
|
|
if strings.Contains(dockerDir, target) {
|
|
|
|
exclusionRules += ("1Panel" + strings.ReplaceAll(dockerDir, target, "") + ";")
|
|
|
|
exclusionRules += ("1panel" + strings.ReplaceAll(dockerDir, target, "") + ";")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if err := u.handleTar(target, fmt.Sprintf("%s/original", filepath.Join(source, "../")), "1panel_data.tar.gz", exclusionRules); err != nil {
|
|
|
|
if err := u.handleTar(target, fmt.Sprintf("%s/original", filepath.Join(source, "../")), "1panel_data.tar.gz", exclusionRules); err != nil {
|
|
|
|
return fmt.Errorf("restore original panel data failed, err: %v", err)
|
|
|
|
return fmt.Errorf("restore original panel data failed, err: %v", err)
|
|
|
@ -779,24 +778,22 @@ func (u *SnapshotService) handleTar(sourceDir, targetDir, name, exclusionRules s
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
exStr := []string{"--warning=no-file-changed"}
|
|
|
|
|
|
|
|
exStr = append(exStr, "-zcf")
|
|
|
|
exStr := ""
|
|
|
|
exStr = append(exStr, targetDir+"/"+name)
|
|
|
|
|
|
|
|
excludes := strings.Split(exclusionRules, ";")
|
|
|
|
excludes := strings.Split(exclusionRules, ";")
|
|
|
|
for _, exclude := range excludes {
|
|
|
|
for _, exclude := range excludes {
|
|
|
|
if len(exclude) == 0 {
|
|
|
|
if len(exclude) == 0 {
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
}
|
|
|
|
exStr = append(exStr, "--exclude")
|
|
|
|
exStr += " --exclude "
|
|
|
|
exStr = append(exStr, exclude)
|
|
|
|
exStr += exclude
|
|
|
|
}
|
|
|
|
}
|
|
|
|
exStr = append(exStr, "-C")
|
|
|
|
|
|
|
|
exStr = append(exStr, sourceDir)
|
|
|
|
ss := fmt.Sprintf("tar zcf %s %s -C %s .", targetDir+"/"+name, exStr, sourceDir)
|
|
|
|
exStr = append(exStr, ".")
|
|
|
|
fmt.Println(ss)
|
|
|
|
cmd := exec.Command("tar", exStr...)
|
|
|
|
stdout, err := cmd.Exec(ss)
|
|
|
|
stdout, err := cmd.CombinedOutput()
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return errors.New(string(stdout))
|
|
|
|
return errors.New(stdout)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -807,14 +804,7 @@ func (u *SnapshotService) handleUnTar(sourceDir, targetDir string) error {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
exStr := []string{}
|
|
|
|
stdout, err := cmd.Exec(fmt.Sprintf("tar zxf %s -C %s .", sourceDir, targetDir))
|
|
|
|
exStr = append(exStr, "zxf")
|
|
|
|
|
|
|
|
exStr = append(exStr, sourceDir)
|
|
|
|
|
|
|
|
exStr = append(exStr, "-C")
|
|
|
|
|
|
|
|
exStr = append(exStr, targetDir)
|
|
|
|
|
|
|
|
exStr = append(exStr, ".")
|
|
|
|
|
|
|
|
cmd := exec.Command("tar", exStr...)
|
|
|
|
|
|
|
|
stdout, err := cmd.CombinedOutput()
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return errors.New(string(stdout))
|
|
|
|
return errors.New(string(stdout))
|
|
|
|
}
|
|
|
|
}
|
|
|
|