Blame SOURCES/bz1350875-disaster-recovery-with-copies.patch

e1ecd9
From 2109f199de8a5af1e33ebd79f90fff0969f72a50 Mon Sep 17 00:00:00 2001
634469
From: Jan Chaloupka <jchaloup@redhat.com>
e1ecd9
Date: Tue, 8 Jan 2019 10:53:19 +0100
e1ecd9
Subject: [PATCH] bz1350875-disaster-recovery-with-copies
634469
634469
---
634469
 etcdctl/ctlv2/command/backup_command.go | 19 +++++++++++++++++--
634469
 1 file changed, 17 insertions(+), 2 deletions(-)
634469
634469
diff --git a/etcdctl/ctlv2/command/backup_command.go b/etcdctl/ctlv2/command/backup_command.go
e1ecd9
index 82e61d8..d7aceed 100644
634469
--- a/etcdctl/ctlv2/command/backup_command.go
634469
+++ b/etcdctl/ctlv2/command/backup_command.go
e1ecd9
@@ -21,6 +21,7 @@ import (
e1ecd9
 	"path"
634469
 	"path/filepath"
e1ecd9
 	"regexp"
634469
+	"strconv"
634469
 	"time"
634469
 
634469
 	"github.com/coreos/etcd/etcdserver/etcdserverpb"
e1ecd9
@@ -48,6 +49,8 @@ func NewBackupCommand() cli.Command {
634469
 			cli.StringFlag{Name: "backup-dir", Value: "", Usage: "Path to the backup dir"},
634469
 			cli.StringFlag{Name: "backup-wal-dir", Value: "", Usage: "Path to the backup wal dir"},
e1ecd9
 			cli.BoolFlag{Name: "with-v3", Usage: "Backup v3 backend data"},
634469
+			cli.BoolFlag{Name: "keep-cluster-id", Usage: "Do not rewrite the cluster id"},
634469
+			cli.StringFlag{Name: "node-id", Value: "", Usage: "Use custom node id instead of a random value"},
634469
 		},
634469
 		Action: handleBackup,
634469
 	}
e1ecd9
@@ -83,8 +86,20 @@ func handleBackup(c *cli.Context) error {
e1ecd9
 	saveDB(filepath.Join(destSnap, "db"), filepath.Join(srcSnap, "db"), state.Commit, withV3)
e1ecd9
 
634469
 	idgen := idutil.NewGenerator(0, time.Now())
634469
-	metadata.NodeID = idgen.Next()
634469
-	metadata.ClusterID = idgen.Next()
634469
+	explicitNodeId := c.String("node-id")
634469
+	if explicitNodeId != "" {
e1ecd9
+		var err error
634469
+		metadata.NodeID, err = strconv.ParseUint(explicitNodeId, 16, 64)
634469
+		if err != nil {
634469
+			log.Fatal(err)
634469
+		}
634469
+	} else {
634469
+		metadata.NodeID = idgen.Next()
634469
+	}
634469
+	keepClusterId := c.Bool("keep-cluster-id")
634469
+	if !keepClusterId {
634469
+		metadata.ClusterID = idgen.Next()
634469
+	}
634469
 
634469
 	neww, err := wal.Create(destWAL, pbutil.MustMarshal(&metadata))
634469
 	if err != nil {
634469
-- 
e1ecd9
2.7.5
634469