diff --git a/backend/app/service/backup_app.go b/backend/app/service/backup_app.go index f6dbe10de..979a5b8a6 100644 --- a/backend/app/service/backup_app.go +++ b/backend/app/service/backup_app.go @@ -255,7 +255,7 @@ func handleAppRecover(install *model.AppInstall, recoverFile string, isRollback func reCreateDB(dbID uint, app model.AppInstall, oldEnv string) (*model.DatabaseMysql, map[string]interface{}, error) { mysqlService := NewIMysqlService() ctx := context.Background() - _ = mysqlService.Delete(ctx, dto.MysqlDBDelete{ID: dbID, Database: app.Name, Type: app.App.Key, DeleteBackup: true, ForceDelete: true}) + _ = mysqlService.Delete(ctx, dto.MysqlDBDelete{ID: dbID, Database: app.Name, Type: app.App.Key, DeleteBackup: false, ForceDelete: true}) envMap := make(map[string]interface{}) if err := json.Unmarshal([]byte(oldEnv), &envMap); err != nil { diff --git a/backend/app/service/database_mysql.go b/backend/app/service/database_mysql.go index 1b2af16be..8e8f89da3 100644 --- a/backend/app/service/database_mysql.go +++ b/backend/app/service/database_mysql.go @@ -235,11 +235,11 @@ func (u *MysqlService) Delete(ctx context.Context, req dto.MysqlDBDelete) error return err } - uploadDir := path.Join(global.CONF.System.BaseDir, fmt.Sprintf("1panel/uploads/database/%s/%s/%s", req.Type, req.Database, db.Name)) - if _, err := os.Stat(uploadDir); err == nil { - _ = os.RemoveAll(uploadDir) - } if req.DeleteBackup { + uploadDir := path.Join(global.CONF.System.BaseDir, fmt.Sprintf("1panel/uploads/database/%s/%s/%s", req.Type, req.Database, db.Name)) + if _, err := os.Stat(uploadDir); err == nil { + _ = os.RemoveAll(uploadDir) + } localDir, err := loadLocalDir() if err != nil && !req.ForceDelete { return err @@ -248,9 +248,9 @@ func (u *MysqlService) Delete(ctx context.Context, req dto.MysqlDBDelete) error if _, err := os.Stat(backupDir); err == nil { _ = os.RemoveAll(backupDir) } + _ = backupRepo.DeleteRecord(ctx, commonRepo.WithByType(req.Type), commonRepo.WithByName(req.Database), backupRepo.WithByDetailName(db.Name)) global.LOG.Infof("delete database %s-%s backups successful", req.Database, db.Name) } - _ = backupRepo.DeleteRecord(ctx, commonRepo.WithByType(req.Type), commonRepo.WithByName(req.Database), backupRepo.WithByDetailName(db.Name)) _ = mysqlRepo.Delete(ctx, commonRepo.WithByID(db.ID)) return nil