Skip to content

Commit

Permalink
Run dump command in bash shell (#228)
Browse files Browse the repository at this point in the history
Signed-off-by: Anisur Rahman <anisur@appscode.com>
  • Loading branch information
anisurrahman75 authored Dec 17, 2024
1 parent fb4061f commit 0cab85a
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion pkg/restic/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import (

const (
ResticCMD = "/bin/restic"
BashCMD = "/bin/bash"
)

type Snapshot struct {
Expand Down Expand Up @@ -438,7 +439,13 @@ func (w *ResticWrapper) run(commands ...Command) ([]byte, error) {
return nil, err
}
}
w.sh.Command(cmd.Name, cmd.Args...)

// Executes Bash commands with "-c" for multiple dump args.
if cmd.Name == BashCMD {
w.sh.Command(cmd.Name, "-c", cmd.getCommandArgsAsString())
} else {
w.sh.Command(cmd.Name, cmd.Args...)
}
}
out, err := w.sh.Output()
if err != nil {
Expand Down Expand Up @@ -581,3 +588,11 @@ func (w *ResticWrapper) appendInsecureTLSFlag(args []interface{}) []interface{}
}
return args
}

func (c *Command) getCommandArgsAsString() string {
var cmdParts []string
for _, arg := range c.Args {
cmdParts = append(cmdParts, fmt.Sprintf("%v", arg))
}
return strings.Join(cmdParts, " ")
}

0 comments on commit 0cab85a

Please sign in to comment.