Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: influx_inspect export from a single tsm file #25530

Open
wants to merge 1 commit into
base: master-1.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions cmd/influx_inspect/export/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type Command struct {
out string
database string
retentionPolicy string
tsmFile string
startTime int64
endTime int64
compress bool
Expand Down Expand Up @@ -71,6 +72,7 @@ func (cmd *Command) Run(args ...string) error {
fs.StringVar(&cmd.out, "out", os.Getenv("HOME")+"/.influxdb/export", "'-' for standard out or the destination file to export to")
fs.StringVar(&cmd.database, "database", "", "Optional: the database to export")
fs.StringVar(&cmd.retentionPolicy, "retention", "", "Optional: the retention policy to export (requires -database)")
fs.StringVar(&cmd.tsmFile, "tsmfile", "", "Optional: path to a single tsm file to export (requires -database and -retention")
fs.StringVar(&start, "start", "", "Optional: the start time to export (RFC3339 format)")
fs.StringVar(&end, "end", "", "Optional: the end time to export (RFC3339 format)")
fs.BoolVar(&cmd.lponly, "lponly", false, "Only export line protocol")
Expand Down Expand Up @@ -119,13 +121,23 @@ func (cmd *Command) validate() error {
if cmd.retentionPolicy != "" && cmd.database == "" {
return fmt.Errorf("must specify a db")
}
if cmd.tsmFile != "" && (cmd.database == "" || cmd.retentionPolicy == "") {
return fmt.Errorf("must specify a db and retention policy")
}
if cmd.startTime != 0 && cmd.endTime != 0 && cmd.endTime < cmd.startTime {
return fmt.Errorf("end time before start time")
}
return nil
}

func (cmd *Command) export() error {
if cmd.tsmFile != "" {
key := cmd.database + string(os.PathSeparator) + cmd.retentionPolicy
cmd.manifest[key] = struct{}{}
cmd.tsmFiles[key] = []string{cmd.tsmFile}
return cmd.write()
}

if err := cmd.walkTSMFiles(); err != nil {
return err
}
Expand Down