etcdctl/backup_command: handle datadir with missed snapshot mark

This helps to recover from the data dir created in v2.0.0-rc1.
This commit is contained in:
Yicheng Qin
2015-01-29 11:38:52 -08:00
parent 7840d49ae0
commit e966e565c4
2 changed files with 11 additions and 5 deletions

View File

@ -15,6 +15,7 @@
package command
import (
"fmt"
"log"
"os"
"path"
@ -71,7 +72,12 @@ func handleBackup(c *cli.Context) {
}
defer w.Close()
wmetadata, state, ents, err := w.ReadAll()
if err != nil {
switch err {
case nil:
case wal.ErrSnapshotNotFound:
fmt.Printf("Failed to find the match snapshot record %+v in wal %v.", walsnap, srcWAL)
fmt.Printf("etcdctl will add it back. Start auto fixing...")
default:
log.Fatal(err)
}
var metadata etcdserverpb.Metadata