1
0
Fork 0
mirror of https://github.com/chrislusf/seaweedfs synced 2024-07-03 23:56:41 +02:00

weed shell: fs.meta.save adjusts meta data file name

This commit is contained in:
Chris Lu 2019-04-16 09:40:27 -07:00
parent 8ea1ee6dfa
commit af49aea0c6
2 changed files with 14 additions and 6 deletions

View file

@ -26,7 +26,7 @@ func (c *commandFsMetaLoad) Name() string {
func (c *commandFsMetaLoad) Help() string { func (c *commandFsMetaLoad) Help() string {
return `load saved filer meta data to restore the directory and file structure return `load saved filer meta data to restore the directory and file structure
fs.meta.load <filer_host>_<port>.meta fs.meta.load <filer_host>-<port>-<time>.meta
` `
} }

View file

@ -5,6 +5,7 @@ import (
"fmt" "fmt"
"io" "io"
"os" "os"
"time"
"github.com/chrislusf/seaweedfs/weed/filer2" "github.com/chrislusf/seaweedfs/weed/filer2"
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb" "github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
@ -24,12 +25,17 @@ func (c *commandFsMetaSave) Name() string {
} }
func (c *commandFsMetaSave) Help() string { func (c *commandFsMetaSave) Help() string {
return `recursively save directory and file meta data to a local file return `save all directory and file meta data to a local file for metadata backup.
fs.meta.save # save current meta data from current directory fs.meta.save / # save from the root
fs.meta.save /path/to/save # save from the directory /path/to/save
fs.meta.save . # save from current directory
fs.meta.save # save from current directory
The meta data will be saved into a local <filer_host>_<port>.meta file. The meta data will be saved into a local <filer_host>-<port>-<time>.meta file.
These meta data can be later loaded by fs.meta.load command. These meta data can be later loaded by fs.meta.load command,
This assumes there are no deletions, so this is different from taking a snapshot.
` `
} }
@ -45,7 +51,9 @@ func (c *commandFsMetaSave) Do(args []string, commandEnv *commandEnv, writer io.
return commandEnv.withFilerClient(ctx, filerServer, filerPort, func(client filer_pb.SeaweedFilerClient) error { return commandEnv.withFilerClient(ctx, filerServer, filerPort, func(client filer_pb.SeaweedFilerClient) error {
fileName := fmt.Sprintf("%s-%d.meta", filerServer, filerPort) t := time.Now()
fileName := fmt.Sprintf("%s-%d-%4d%02d%02d-%02d%02d%02d.meta",
filerServer, filerPort, t.Year(), t.Month(), t.Day(), t.Hour(), t.Minute(), t.Second())
dst, err := os.OpenFile(fileName, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644) dst, err := os.OpenFile(fileName, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
if err != nil { if err != nil {