split into packages

This commit is contained in:
Sam Hoffman
2026-01-30 16:59:42 -05:00
parent 94d56cdbb2
commit 65cd90621b
3 changed files with 175 additions and 174 deletions

31
internal/zfs/zfs.go Normal file
View File

@@ -0,0 +1,31 @@
package zfs
import (
"context"
"fmt"
"os/exec"
"time"
)
type Snapshot struct {
SnapshotName string // Name sans dataset (the part after the '@')
Name string // Full dataset@snapname
Dataset string
Creation time.Time
GUID int64
}
func Cmd(ctx context.Context, arg string, a ...any) ([]byte, error) {
if len(a) > 0 {
arg = fmt.Sprintf(arg, a...)
}
cmd := exec.CommandContext(ctx, "/bin/sh", "-c", arg)
fmt.Printf("zfs: %+v\n", arg)
out, err := cmd.CombinedOutput()
if err != nil {
return out, err
}
return out, err
}