From e2a7c51de0232ad1029e0cf7f1c4e3f8fa4a2611 Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Wed, 7 Jun 2023 10:49:22 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=A4=87=E4=BB=BD=E9=80=82=E9=85=8D=20r?= =?UTF-8?q?edis=20=E7=89=88=E6=9C=AC=20(#1271)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/service/backup_redis.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/backend/app/service/backup_redis.go b/backend/app/service/backup_redis.go index 93b63fbae..09e9cae77 100644 --- a/backend/app/service/backup_redis.go +++ b/backend/app/service/backup_redis.go @@ -37,7 +37,7 @@ func (u *BackupService) RedisBackup() error { timeNow := time.Now().Format("20060102150405") fileName := fmt.Sprintf("%s.rdb", timeNow) if appendonly == "yes" { - if redisInfo.Version == "6.0.16" { + if strings.HasPrefix(redisInfo.Version, "6.") { fileName = fmt.Sprintf("%s.aof", timeNow) } else { fileName = fmt.Sprintf("%s.tar.gz", timeNow) @@ -120,10 +120,10 @@ func handleRedisRecover(redisInfo *repo.RootInfo, recoverFile string, isRollback } if appendonly == "yes" { - if redisInfo.Version == "6.0.16" && !strings.HasSuffix(recoverFile, ".aof") { + if strings.HasPrefix(redisInfo.Version, "6.") && !strings.HasSuffix(recoverFile, ".aof") { return buserr.New(constant.ErrTypeOfRedis) } - if redisInfo.Version == "7.0.5" && !strings.HasSuffix(recoverFile, ".tar.gz") { + if strings.HasPrefix(redisInfo.Version, "7.") && !strings.HasSuffix(recoverFile, ".tar.gz") { return buserr.New(constant.ErrTypeOfRedis) } } else { @@ -137,7 +137,7 @@ func handleRedisRecover(redisInfo *repo.RootInfo, recoverFile string, isRollback if !isRollback { suffix := "rdb" if appendonly == "yes" { - if redisInfo.Version == "6.0.16" { + if strings.HasPrefix(redisInfo.Version, "6.") { suffix = "aof" } else { suffix = "tar.gz" @@ -165,14 +165,14 @@ func handleRedisRecover(redisInfo *repo.RootInfo, recoverFile string, isRollback if _, err := compose.Down(composeDir + "/docker-compose.yml"); err != nil { return err } - if appendonly == "yes" && redisInfo.Version == "7.0.5" { + if appendonly == "yes" && strings.HasPrefix(redisInfo.Version, "7.") { redisDataDir := fmt.Sprintf("%s/%s/%s/data", constant.AppInstallDir, "redis", redisInfo.Name) if err := handleUnTar(recoverFile, redisDataDir); err != nil { return err } } else { itemName := "dump.rdb" - if appendonly == "yes" && redisInfo.Version == "6.0.16" { + if appendonly == "yes" && strings.HasPrefix(redisInfo.Version, "6.") { itemName = "appendonly.aof" } input, err := os.ReadFile(recoverFile)