mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #1781 from orls/fix-backup-snapshots
Fix backup snapshots
This commit is contained in:
commit
aa2721e31d
@ -19,6 +19,7 @@ package command
|
||||
import (
|
||||
"log"
|
||||
"math/rand"
|
||||
"os"
|
||||
"path"
|
||||
"time"
|
||||
|
||||
@ -49,6 +50,9 @@ func handleBackup(c *cli.Context) {
|
||||
srcWAL := path.Join(c.String("data-dir"), "wal")
|
||||
destWAL := path.Join(c.String("backup-dir"), "wal")
|
||||
|
||||
if err := os.MkdirAll(destSnap, 0700); err != nil {
|
||||
log.Fatalf("failed creating backup snapshot dir %v: %v", destSnap, err)
|
||||
}
|
||||
ss := snap.New(srcSnap)
|
||||
snapshot, err := ss.Load()
|
||||
if err != nil && err != snap.ErrNoSnapshot {
|
||||
@ -58,7 +62,9 @@ func handleBackup(c *cli.Context) {
|
||||
if snapshot != nil {
|
||||
index = snapshot.Index
|
||||
newss := snap.New(destSnap)
|
||||
newss.SaveSnap(*snapshot)
|
||||
if err := newss.SaveSnap(*snapshot); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
w, err := wal.OpenAtIndex(srcWAL, index)
|
||||
|
Loading…
x
Reference in New Issue
Block a user