replace use of shell w/ direct calls
This commit is contained in:
@@ -10,6 +10,8 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"git.gentoo.party/sam/thanks/internal/runner"
|
||||
)
|
||||
|
||||
type Snapshot struct {
|
||||
@@ -113,3 +115,49 @@ func Snapshots(ctx context.Context, target string) ([]Snapshot, error) {
|
||||
|
||||
return snaps, err
|
||||
}
|
||||
|
||||
func FullSend(ctx context.Context, snap, sshTarget, target string) ([]byte, error) {
|
||||
return runner.Pipeline(
|
||||
exec.CommandContext(
|
||||
ctx,
|
||||
"zfs",
|
||||
"send",
|
||||
"-Lec",
|
||||
snap,
|
||||
),
|
||||
exec.CommandContext(
|
||||
ctx,
|
||||
"ssh",
|
||||
sshTarget,
|
||||
"zfs",
|
||||
"recv",
|
||||
"-Fu",
|
||||
target,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
func IncrementalSend(ctx context.Context, prevSnapName, newSnapName, sshTarget, target string) ([]byte, error) {
|
||||
return runner.Pipeline(
|
||||
exec.CommandContext(
|
||||
ctx,
|
||||
"zfs",
|
||||
"send",
|
||||
fmt.Sprintf("-I@%s", prevSnapName),
|
||||
newSnapName,
|
||||
),
|
||||
exec.CommandContext(
|
||||
ctx,
|
||||
"ssh",
|
||||
sshTarget,
|
||||
"zfs",
|
||||
"recv",
|
||||
target,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
func Destroy(ctx context.Context, target string) ([]byte, error) {
|
||||
cmd := exec.CommandContext(ctx, "zfs", "destroy", target)
|
||||
return cmd.CombinedOutput()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user