From 1dde65bb75f3744c01313f5bd8f54f0262dd0da4 Mon Sep 17 00:00:00 2001 From: davidby-influx <72418212+davidby-influx@users.noreply.github.com> Date: Wed, 22 Sep 2021 08:50:32 -0700 Subject: [PATCH] fix(restore): enforce the -db parameter when -newdb used (#22542) closes https://github.com/influxdata/influxdb/issues/15901 --- cmd/influxd/restore/restore.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmd/influxd/restore/restore.go b/cmd/influxd/restore/restore.go index aa5c54cd9b..edba3450c9 100644 --- a/cmd/influxd/restore/restore.go +++ b/cmd/influxd/restore/restore.go @@ -166,6 +166,10 @@ func (cmd *Command) parseFlags(args []string) error { return fmt.Errorf("backup path should be a valid directory: %s", cmd.backupFilesPath) } + if cmd.destinationDatabase != "" && cmd.sourceDatabase == "" { + return fmt.Errorf("must specify a database to be restored into new database %s", cmd.destinationDatabase) + } + if cmd.portable || cmd.online { // validate the arguments @@ -183,6 +187,7 @@ func (cmd *Command) parseFlags(args []string) error { if cmd.portable { var err error + cmd.manifestMeta, cmd.manifestFiles, err = backup_util.LoadIncremental(cmd.backupFilesPath) if err != nil { return fmt.Errorf("restore failed while processing manifest files: %s", err.Error())