|
@@ -20,7 +20,6 @@ import (
|
|
|
"path/filepath"
|
|
"path/filepath"
|
|
|
"strings"
|
|
"strings"
|
|
|
|
|
|
|
|
- "github.com/coreos/etcd/pkg/types"
|
|
|
|
|
"github.com/coreos/etcd/snapshot"
|
|
"github.com/coreos/etcd/snapshot"
|
|
|
|
|
|
|
|
"github.com/spf13/cobra"
|
|
"github.com/spf13/cobra"
|
|
@@ -104,10 +103,11 @@ func snapshotSaveCommandFunc(cmd *cobra.Command, args []string) {
|
|
|
if debug {
|
|
if debug {
|
|
|
lg = zap.NewExample()
|
|
lg = zap.NewExample()
|
|
|
}
|
|
}
|
|
|
- sp := snapshot.NewV3(mustClientFromCmd(cmd), lg)
|
|
|
|
|
|
|
+ sp := snapshot.NewV3(lg)
|
|
|
|
|
+ cfg := mustClientCfgFromCmd(cmd)
|
|
|
|
|
|
|
|
path := args[0]
|
|
path := args[0]
|
|
|
- if err := sp.Save(context.TODO(), path); err != nil {
|
|
|
|
|
|
|
+ if err := sp.Save(context.TODO(), *cfg, path); err != nil {
|
|
|
ExitWithError(ExitInterrupted, err)
|
|
ExitWithError(ExitInterrupted, err)
|
|
|
}
|
|
}
|
|
|
fmt.Printf("Snapshot saved at %s\n", path)
|
|
fmt.Printf("Snapshot saved at %s\n", path)
|
|
@@ -128,8 +128,7 @@ func snapshotStatusCommandFunc(cmd *cobra.Command, args []string) {
|
|
|
if debug {
|
|
if debug {
|
|
|
lg = zap.NewExample()
|
|
lg = zap.NewExample()
|
|
|
}
|
|
}
|
|
|
- sp := snapshot.NewV3(nil, lg)
|
|
|
|
|
-
|
|
|
|
|
|
|
+ sp := snapshot.NewV3(lg)
|
|
|
ds, err := sp.Status(args[0])
|
|
ds, err := sp.Status(args[0])
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
ExitWithError(ExitError, err)
|
|
ExitWithError(ExitError, err)
|
|
@@ -143,11 +142,6 @@ func snapshotRestoreCommandFunc(cmd *cobra.Command, args []string) {
|
|
|
ExitWithError(ExitBadArgs, err)
|
|
ExitWithError(ExitBadArgs, err)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- urlmap, uerr := types.NewURLsMap(restoreCluster)
|
|
|
|
|
- if uerr != nil {
|
|
|
|
|
- ExitWithError(ExitBadArgs, uerr)
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
dataDir := restoreDataDir
|
|
dataDir := restoreDataDir
|
|
|
if dataDir == "" {
|
|
if dataDir == "" {
|
|
|
dataDir = restoreName + ".etcd"
|
|
dataDir = restoreName + ".etcd"
|
|
@@ -166,15 +160,16 @@ func snapshotRestoreCommandFunc(cmd *cobra.Command, args []string) {
|
|
|
if debug {
|
|
if debug {
|
|
|
lg = zap.NewExample()
|
|
lg = zap.NewExample()
|
|
|
}
|
|
}
|
|
|
- sp := snapshot.NewV3(nil, lg)
|
|
|
|
|
|
|
+ sp := snapshot.NewV3(lg)
|
|
|
|
|
|
|
|
- if err := sp.Restore(args[0], snapshot.RestoreConfig{
|
|
|
|
|
|
|
+ if err := sp.Restore(snapshot.RestoreConfig{
|
|
|
|
|
+ SnapshotPath: args[0],
|
|
|
Name: restoreName,
|
|
Name: restoreName,
|
|
|
OutputDataDir: dataDir,
|
|
OutputDataDir: dataDir,
|
|
|
OutputWALDir: walDir,
|
|
OutputWALDir: walDir,
|
|
|
- InitialCluster: urlmap,
|
|
|
|
|
|
|
+ PeerURLs: strings.Split(restorePeerURLs, ","),
|
|
|
|
|
+ InitialCluster: restoreCluster,
|
|
|
InitialClusterToken: restoreClusterToken,
|
|
InitialClusterToken: restoreClusterToken,
|
|
|
- PeerURLs: types.MustNewURLs(strings.Split(restorePeerURLs, ",")),
|
|
|
|
|
SkipHashCheck: skipHashCheck,
|
|
SkipHashCheck: skipHashCheck,
|
|
|
}); err != nil {
|
|
}); err != nil {
|
|
|
ExitWithError(ExitError, err)
|
|
ExitWithError(ExitError, err)
|