From 3978fb3e466154b2913b449a9a8b5e057b43c413 Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Thu, 29 Jun 2023 11:24:11 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E5=BF=AB=E7=85=A7?= =?UTF-8?q?=E5=8E=8B=E7=BC=A9=E6=95=B0=E6=8D=AE=E5=BA=93=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E7=9A=84=E9=97=AE=E9=A2=98=20(#1477)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/service/snapshot.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/backend/app/service/snapshot.go b/backend/app/service/snapshot.go index 9779072ed..09ce7594a 100644 --- a/backend/app/service/snapshot.go +++ b/backend/app/service/snapshot.go @@ -208,7 +208,9 @@ func (u *SnapshotService) SnapshotCreate(req dto.SnapshotCreate) error { global.LOG.Infof("start to upload snapshot to %s, please wait", backup.Type) _ = snapshotRepo.Update(snap.ID, map[string]interface{}{"status": constant.StatusUploading}) localPath := fmt.Sprintf("%s/system/1panel_%s_%s.tar.gz", localDir, versionItem.Value, timeNow) - if ok, err := backupAccount.Upload(localPath, fmt.Sprintf("system_snapshot/1panel_%s_%s.tar.gz", versionItem.Value, timeNow)); err != nil || !ok { + itemBackupPath := strings.TrimLeft(backup.BackupPath, "/") + itemBackupPath = strings.TrimRight(itemBackupPath, "/") + if ok, err := backupAccount.Upload(localPath, fmt.Sprintf("%s/system_snapshot/1panel_%s_%s.tar.gz", itemBackupPath, versionItem.Value, timeNow)); err != nil || !ok { _ = snapshotRepo.Update(snap.ID, map[string]interface{}{"status": constant.StatusFailed, "message": err.Error()}) global.LOG.Errorf("upload snapshot to %s failed, err: %v", backup.Type, err) return @@ -259,7 +261,9 @@ func (u *SnapshotService) SnapshotRecover(req dto.SnapshotRecover) error { operation = "re-recover" } if !isReTry || snap.InterruptStep == "Download" || (isReTry && req.ReDownload) { - ok, err := client.Download(fmt.Sprintf("system_snapshot/%s.tar.gz", snap.Name), fmt.Sprintf("%s/%s.tar.gz", baseDir, snap.Name)) + itemBackupPath := strings.TrimLeft(backup.BackupPath, "/") + itemBackupPath = strings.TrimRight(itemBackupPath, "/") + ok, err := client.Download(fmt.Sprintf("%s/system_snapshot/%s.tar.gz", itemBackupPath, snap.Name), fmt.Sprintf("%s/%s.tar.gz", baseDir, snap.Name)) if err != nil || !ok { if req.ReDownload { updateRecoverStatus(snap.ID, snap.InterruptStep, constant.StatusFailed, fmt.Sprintf("download file %s from %s failed, err: %v", snap.Name, backup.Type, err)) @@ -664,7 +668,7 @@ func (u *SnapshotService) handleBackupDatas(fileOp files.FileOp, operation strin func (u *SnapshotService) handlePanelDatas(snapID uint, fileOp files.FileOp, operation string, source, target, backupDir, dockerDir string) error { switch operation { case "snapshot": - exclusionRules := "./tmp;./cache;" + exclusionRules := "./tmp;./cache;./db/1Panel.db-*;" if strings.Contains(backupDir, source) { exclusionRules += ("." + strings.ReplaceAll(backupDir, source, "") + ";") }