diff options
Diffstat (limited to 'go/weed/export.go')
| -rw-r--r-- | go/weed/export.go | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/go/weed/export.go b/go/weed/export.go index 7b2fdb817..f1634dbd1 100644 --- a/go/weed/export.go +++ b/go/weed/export.go @@ -15,15 +15,21 @@ import ( "github.com/chrislusf/seaweedfs/go/storage" ) -func init() { - cmdExport.Run = runExport // break init cycle -} - const ( defaultFnFormat = `{{.Mime}}/{{.Id}}:{{.Name}}` timeFormat = "2006-01-02T15:04:05" ) +var ( + export ExportOptions +) + +type ExportOptions struct { + dir *string + collection *string + volumeId *int +} + var cmdExport = &Command{ UsageLine: "export -dir=/tmp -volumeId=234 -o=/dir/name.tar -fileNameFormat={{.Name}} -newer='" + timeFormat + "'", Short: "list or export files from one volume data file", @@ -34,13 +40,17 @@ var cmdExport = &Command{ `, } +func init() { + cmdExport.Run = runExport // break init cycle + export.dir = cmdExport.Flag.String("dir", ".", "input data directory to store volume data files") + export.collection = cmdExport.Flag.String("collection", "", "the volume collection name") + export.volumeId = cmdExport.Flag.Int("volumeId", -1, "a volume id. The volume .dat and .idx files should already exist in the dir.") + dest = cmdExport.Flag.String("o", "", "output tar file name, must ends with .tar, or just a \"-\" for stdout") + format = cmdExport.Flag.String("fileNameFormat", defaultFnFormat, "filename format, default to {{.Mime}}/{{.Id}}:{{.Name}}") + newer = cmdExport.Flag.String("newer", "", "export only files newer than this time, default is all files. Must be specified in RFC3339 without timezone") +} + var ( - exportVolumePath = cmdExport.Flag.String("dir", ".", "input data directory to store volume data files") - exportCollection = cmdExport.Flag.String("collection", "", "the volume collection name") - exportVolumeId = cmdExport.Flag.Int("volumeId", -1, "a volume id. The volume .dat and .idx files should already exist in the dir.") - dest = cmdExport.Flag.String("o", "", "output tar file name, must ends with .tar, or just a \"-\" for stdout") - format = cmdExport.Flag.String("fileNameFormat", defaultFnFormat, "filename format, default to {{.Mime}}/{{.Id}}:{{.Name}}") - newer = cmdExport.Flag.String("newer", "", "export only files newer than this time, default is all files. Must be specified in RFC3339 without timezone") tarFh *tar.Writer tarHeader tar.Header fnTmpl *template.Template |
