|
|
798799 |
--- etcd-2.3.7/etcdctl/command/backup_command.go.orig 2016-08-01 17:43:46.149281982 +0200
|
|
|
798799 |
+++ etcd-2.3.7/etcdctl/command/backup_command.go 2016-08-01 17:43:47.988279830 +0200
|
|
|
798799 |
@@ -19,6 +19,7 @@ import (
|
|
|
798799 |
"log"
|
|
|
798799 |
"os"
|
|
|
798799 |
"path"
|
|
|
798799 |
+ "strconv"
|
|
|
798799 |
"time"
|
|
|
798799 |
|
|
|
798799 |
"github.com/coreos/etcd/Godeps/_workspace/src/github.com/codegangsta/cli"
|
|
|
798799 |
@@ -40,6 +41,8 @@ func NewBackupCommand() cli.Command {
|
|
|
798799 |
cli.StringFlag{Name: "wal-dir", Value: "", Usage: "Path to the etcd wal dir"},
|
|
|
798799 |
cli.StringFlag{Name: "backup-dir", Value: "", Usage: "Path to the backup dir"},
|
|
|
798799 |
cli.StringFlag{Name: "backup-wal-dir", Value: "", Usage: "Path to the backup wal dir"},
|
|
|
798799 |
+ cli.BoolFlag{Name: "keep-cluster-id", Usage: "Do not rewrite the cluster id"},
|
|
|
798799 |
+ cli.StringFlag{Name: "node-id", Value: "", Usage: "Use custom node id instead of a random value"},
|
|
|
798799 |
},
|
|
|
798799 |
Action: handleBackup,
|
|
|
798799 |
}
|
|
|
798799 |
@@ -99,8 +102,19 @@ func handleBackup(c *cli.Context) {
|
|
|
798799 |
var metadata etcdserverpb.Metadata
|
|
|
798799 |
pbutil.MustUnmarshal(&metadata, wmetadata)
|
|
|
798799 |
idgen := idutil.NewGenerator(0, time.Now())
|
|
|
798799 |
- metadata.NodeID = idgen.Next()
|
|
|
798799 |
- metadata.ClusterID = idgen.Next()
|
|
|
798799 |
+ explicitNodeId := c.String("node-id")
|
|
|
798799 |
+ if explicitNodeId != "" {
|
|
|
798799 |
+ metadata.NodeID, err = strconv.ParseUint(explicitNodeId, 16, 64)
|
|
|
798799 |
+ if err != nil {
|
|
|
798799 |
+ log.Fatal(err)
|
|
|
798799 |
+ }
|
|
|
798799 |
+ } else {
|
|
|
798799 |
+ metadata.NodeID = idgen.Next()
|
|
|
798799 |
+ }
|
|
|
798799 |
+ keepClusterId := c.Bool("keep-cluster-id")
|
|
|
798799 |
+ if !keepClusterId {
|
|
|
798799 |
+ metadata.ClusterID = idgen.Next()
|
|
|
798799 |
+ }
|
|
|
798799 |
|
|
|
798799 |
neww, err := wal.Create(destWAL, pbutil.MustMarshal(&metadata))
|
|
|
798799 |
if err != nil {
|