mirror of https://github.com/1Panel-dev/1Panel
fix: 应用备份目录从设置中读取
parent
459fc5ba45
commit
098b735c7a
|
@ -243,8 +243,28 @@ func updateInstall(installId uint, detailId uint) error {
|
|||
func backupInstall(ctx context.Context, install model.AppInstall) error {
|
||||
var backup model.AppInstallBackup
|
||||
appPath := install.GetPath()
|
||||
backupDir := path.Join(constant.BackupDir, install.App.Key, install.Name)
|
||||
|
||||
backupAccount, err := backupRepo.Get(commonRepo.WithByType("LOCAL"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
varMap := make(map[string]interface{})
|
||||
if err := json.Unmarshal([]byte(backupAccount.Vars), &varMap); err != nil {
|
||||
return err
|
||||
}
|
||||
dir, ok := varMap["dir"]
|
||||
if !ok {
|
||||
return errors.New("load local backup dir failed")
|
||||
}
|
||||
baseDir, ok := dir.(string)
|
||||
if !ok {
|
||||
return errors.New("load local backup dir failed")
|
||||
}
|
||||
backupDir := path.Join(baseDir, "apps", install.App.Key, install.Name)
|
||||
fileOp := files.NewFileOp()
|
||||
if !fileOp.Stat(backupDir) {
|
||||
_ = fileOp.CreateDir(backupDir, 0775)
|
||||
}
|
||||
now := time.Now()
|
||||
day := now.Format("20060102150405")
|
||||
fileName := fmt.Sprintf("%s_%s%s", install.Name, day, ".tar.gz")
|
||||
|
|
|
@ -10,6 +10,4 @@ var (
|
|||
ResourceDir = path.Join(DefaultDataDir, "resource")
|
||||
AppResourceDir = path.Join(ResourceDir, "apps")
|
||||
AppInstallDir = path.Join(DefaultDataDir, "apps")
|
||||
BackupDir = path.Join(DefaultDataDir, "backup")
|
||||
AppBackupDir = path.Join(BackupDir, "apps")
|
||||
)
|
||||
|
|
|
@ -13,10 +13,8 @@ func Init() {
|
|||
constant.ResourceDir = path.Join(constant.DefaultDataDir, "resource")
|
||||
constant.AppResourceDir = path.Join(constant.ResourceDir, "apps")
|
||||
constant.AppInstallDir = path.Join(constant.DefaultDataDir, "apps")
|
||||
constant.BackupDir = path.Join(constant.DefaultDataDir, "backup")
|
||||
constant.AppBackupDir = path.Join(constant.BackupDir, "apps")
|
||||
|
||||
dirs := []string{constant.DefaultDataDir, constant.ResourceDir, constant.AppResourceDir, constant.AppInstallDir, constant.BackupDir, constant.AppBackupDir}
|
||||
dirs := []string{constant.DefaultDataDir, constant.ResourceDir, constant.AppResourceDir, constant.AppInstallDir}
|
||||
|
||||
fileOp := files.NewFileOp()
|
||||
for _, dir := range dirs {
|
||||
|
|
Loading…
Reference in New Issue