mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-10-06 05:24:33 +08:00
fix: 备份适配 redis 版本 (#1271)
This commit is contained in:
parent
633e26b1de
commit
e2a7c51de0
1 changed files with 6 additions and 6 deletions
|
@ -37,7 +37,7 @@ func (u *BackupService) RedisBackup() error {
|
||||||
timeNow := time.Now().Format("20060102150405")
|
timeNow := time.Now().Format("20060102150405")
|
||||||
fileName := fmt.Sprintf("%s.rdb", timeNow)
|
fileName := fmt.Sprintf("%s.rdb", timeNow)
|
||||||
if appendonly == "yes" {
|
if appendonly == "yes" {
|
||||||
if redisInfo.Version == "6.0.16" {
|
if strings.HasPrefix(redisInfo.Version, "6.") {
|
||||||
fileName = fmt.Sprintf("%s.aof", timeNow)
|
fileName = fmt.Sprintf("%s.aof", timeNow)
|
||||||
} else {
|
} else {
|
||||||
fileName = fmt.Sprintf("%s.tar.gz", timeNow)
|
fileName = fmt.Sprintf("%s.tar.gz", timeNow)
|
||||||
|
@ -120,10 +120,10 @@ func handleRedisRecover(redisInfo *repo.RootInfo, recoverFile string, isRollback
|
||||||
}
|
}
|
||||||
|
|
||||||
if appendonly == "yes" {
|
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)
|
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)
|
return buserr.New(constant.ErrTypeOfRedis)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -137,7 +137,7 @@ func handleRedisRecover(redisInfo *repo.RootInfo, recoverFile string, isRollback
|
||||||
if !isRollback {
|
if !isRollback {
|
||||||
suffix := "rdb"
|
suffix := "rdb"
|
||||||
if appendonly == "yes" {
|
if appendonly == "yes" {
|
||||||
if redisInfo.Version == "6.0.16" {
|
if strings.HasPrefix(redisInfo.Version, "6.") {
|
||||||
suffix = "aof"
|
suffix = "aof"
|
||||||
} else {
|
} else {
|
||||||
suffix = "tar.gz"
|
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 {
|
if _, err := compose.Down(composeDir + "/docker-compose.yml"); err != nil {
|
||||||
return err
|
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)
|
redisDataDir := fmt.Sprintf("%s/%s/%s/data", constant.AppInstallDir, "redis", redisInfo.Name)
|
||||||
if err := handleUnTar(recoverFile, redisDataDir); err != nil {
|
if err := handleUnTar(recoverFile, redisDataDir); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
itemName := "dump.rdb"
|
itemName := "dump.rdb"
|
||||||
if appendonly == "yes" && redisInfo.Version == "6.0.16" {
|
if appendonly == "yes" && strings.HasPrefix(redisInfo.Version, "6.") {
|
||||||
itemName = "appendonly.aof"
|
itemName = "appendonly.aof"
|
||||||
}
|
}
|
||||||
input, err := os.ReadFile(recoverFile)
|
input, err := os.ReadFile(recoverFile)
|
||||||
|
|
Loading…
Add table
Reference in a new issue