mirror of https://github.com/1Panel-dev/1Panel
fix: 备份适配 redis 版本 (#1271)
parent
633e26b1de
commit
e2a7c51de0
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue