fix(restore): enforce the -db parameter when -newdb used (#22542)

closes https://github.com/influxdata/influxdb/issues/15901
pull/22551/head
davidby-influx 2021-09-22 08:50:32 -07:00 committed by GitHub
parent 6b80ab1f77
commit 1dde65bb75
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 0 deletions

View File

@ -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())