diff --git a/ctl/backup_tar.go b/ctl/backup_tar.go index 961aebb24..c0bf72ac8 100644 --- a/ctl/backup_tar.go +++ b/ctl/backup_tar.go @@ -127,7 +127,7 @@ func (cmd *BackupTarCommand) Run(ctx context.Context) (err error) { // Create output file in temporary location, or send to stdout if a dash is specified. var w io.Writer if useStdout { - w = os.Stdout + w = cmd.Stdout } else { f, err := os.Create(cmd.OutputPath + ".tmp") if err != nil { diff --git a/ctl/restore_tar.go b/ctl/restore_tar.go index a4fc1cef3..480450bb1 100644 --- a/ctl/restore_tar.go +++ b/ctl/restore_tar.go @@ -73,16 +73,17 @@ func (cmd *RestoreTarCommand) Run(ctx context.Context) (err error) { } useStdin := cmd.Path == "-" - var f *os.File + var f io.Reader // read from Stdin if path specified as - if useStdin { - f = os.Stdin + f = cmd.Stdin } else { - f, err = os.Open(cmd.Path) + file, err := os.Open(cmd.Path) if err != nil { return (err) } - defer f.Close() + defer file.Close() + f = file } // Parse TLS configuration for node-specific clients.