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

e4deaa
From e32942895643fbd2db0055b79816e060355d6ca1 Mon Sep 17 00:00:00 2001
e4deaa
From: Jan Chaloupka <jchaloup@redhat.com>
e4deaa
Date: Tue, 21 Feb 2017 12:10:33 +0100
e4deaa
Subject: [PATCH] bz1350875-disaster-recovery-with-copies
e4deaa
e4deaa
---
e4deaa
 etcdctl/ctlv2/command/backup_command.go | 18 ++++++++++++++++--
e4deaa
 1 file changed, 16 insertions(+), 2 deletions(-)
e4deaa
e4deaa
diff --git a/etcdctl/ctlv2/command/backup_command.go b/etcdctl/ctlv2/command/backup_command.go
e4deaa
index 9c7e2ff..0ad6d7a 100644
e4deaa
--- a/etcdctl/ctlv2/command/backup_command.go
e4deaa
+++ b/etcdctl/ctlv2/command/backup_command.go
e4deaa
@@ -18,6 +18,7 @@ import (
e4deaa
 	"fmt"
e4deaa
 	"log"
e4deaa
 	"path"
e4deaa
+	"strconv"
e4deaa
 	"time"
e4deaa
 
e4deaa
 	"github.com/coreos/etcd/etcdserver/etcdserverpb"
e4deaa
@@ -40,6 +41,8 @@ func NewBackupCommand() cli.Command {
e4deaa
 			cli.StringFlag{Name: "wal-dir", Value: "", Usage: "Path to the etcd wal dir"},
e4deaa
 			cli.StringFlag{Name: "backup-dir", Value: "", Usage: "Path to the backup dir"},
e4deaa
 			cli.StringFlag{Name: "backup-wal-dir", Value: "", Usage: "Path to the backup wal dir"},
e4deaa
+			cli.BoolFlag{Name: "keep-cluster-id", Usage: "Do not rewrite the cluster id"},
e4deaa
+			cli.StringFlag{Name: "node-id", Value: "", Usage: "Use custom node id instead of a random value"},
e4deaa
 		},
e4deaa
 		Action: handleBackup,
e4deaa
 	}
e4deaa
@@ -99,8 +102,19 @@ func handleBackup(c *cli.Context) error {
e4deaa
 	var metadata etcdserverpb.Metadata
e4deaa
 	pbutil.MustUnmarshal(&metadata, wmetadata)
e4deaa
 	idgen := idutil.NewGenerator(0, time.Now())
e4deaa
-	metadata.NodeID = idgen.Next()
e4deaa
-	metadata.ClusterID = idgen.Next()
e4deaa
+	explicitNodeId := c.String("node-id")
e4deaa
+	if explicitNodeId != "" {
e4deaa
+		metadata.NodeID, err = strconv.ParseUint(explicitNodeId, 16, 64)
e4deaa
+		if err != nil {
e4deaa
+			log.Fatal(err)
e4deaa
+		}
e4deaa
+	} else {
e4deaa
+		metadata.NodeID = idgen.Next()
e4deaa
+	}
e4deaa
+	keepClusterId := c.Bool("keep-cluster-id")
e4deaa
+	if !keepClusterId {
e4deaa
+		metadata.ClusterID = idgen.Next()
e4deaa
+	}
e4deaa
 
e4deaa
 	neww, err := wal.Create(destWAL, pbutil.MustMarshal(&metadata))
e4deaa
 	if err != nil {
e4deaa
-- 
e4deaa
2.7.4
e4deaa