Skip to content

Commit

Permalink
lxc: Fix exporting vm backups to stdout
Browse files Browse the repository at this point in the history
Signed-off-by: Kadin Sayani <[email protected]>
  • Loading branch information
kadinsayani committed Sep 18, 2024
1 parent 1c2e3c6 commit 2704b3e
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions lxc/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,26 @@ func (c *cmdExport) run(cmd *cobra.Command, args []string) error {
return fmt.Errorf("Create instance backup: %w", err)
}

var targetName string
if len(args) > 1 {
targetName = args[1]
} else {
targetName = name + ".backup"
}

var target *os.File
if targetName == "-" {
target = os.Stdout
c.global.flagQuiet = true
} else {
target, err = os.Create(shared.HostPathFollow(targetName))
if err != nil {
return err
}

defer func() { _ = target.Close() }()
}

// Watch the background operation
progress := cli.ProgressRenderer{
Format: i18n.G("Backing up instance: %s"),
Expand Down Expand Up @@ -127,26 +147,6 @@ func (c *cmdExport) run(cmd *cobra.Command, args []string) error {
}
}()

var targetName string
if len(args) > 1 {
targetName = args[1]
} else {
targetName = name + ".backup"
}

var target *os.File
if targetName == "-" {
target = os.Stdout
c.global.flagQuiet = true
} else {
target, err = os.Create(shared.HostPathFollow(targetName))
if err != nil {
return err
}

defer func() { _ = target.Close() }()
}

// Prepare the download request
progress = cli.ProgressRenderer{
Format: i18n.G("Exporting the backup: %s"),
Expand Down

0 comments on commit 2704b3e

Please sign in to comment.