mistifyio/go-zfs

Function SendSnapshotIncremental

icarbajovallejo opened this issue · 2 comments

Hello all,

I have done a function SendSnapshotIncremental that add the options "-i" et "-I". As I don't know if this project is till active, before to do a pull request, I open this issue.

// SendFlag is the options flags passed to SendSnapshot
type SendFlag int

// Valid send options
const (
	SendDefault              SendFlag = 1 << iota
	IncrementalStream                 = 1 << iota
	IncrementalPackage	          = 1 << iota
)

func SendSnapshotIncremental(output io.Writer, d1 *Dataset, d2 *Dataset, flags SendFlag) error {
	if d1.Type != DatasetSnapshot || d2.Type != DatasetSnapshot {
		return errors.New("can only send snapshots")
	}

	// Flags for SendSnapshot
	option := ""
	if flags&IncrementalStream !=0 {
		option = "-i"
	}
	if flags&IncrementalPackage  !=0 {
		option = "-I"
	}
	c := command{Command: "zfs", Stdout: output}
	_, err := c.Run("send", option, d1.Name, d2.Name)
	return err
}

Anyway, If there are anybody who can improve it, this will be perfect !

Making the pull request would be the best path forward.

=== RUN TestError
--- PASS: TestError (0.00s)
=== RUN TestDatasets
--- PASS: TestDatasets (1.74s)
=== RUN TestDatasetGetProperty
--- PASS: TestDatasetGetProperty (1.77s)
=== RUN TestSnapshots
--- PASS: TestSnapshots (1.73s)
=== RUN TestFilesystems
--- PASS: TestFilesystems (2.84s)
=== RUN TestCreateFilesystemWithProperties
--- PASS: TestCreateFilesystemWithProperties (3.37s)
=== RUN TestVolumes
--- PASS: TestVolumes (3.85s)
=== RUN TestSnapshot
--- PASS: TestSnapshot (3.46s)
=== RUN TestClone
--- PASS: TestClone (4.32s)
=== RUN TestSendSnapshot
--- PASS: TestSendSnapshot (3.45s)
=== RUN TestChildren
--- PASS: TestChildren (3.39s)
=== RUN TestListZpool
--- PASS: TestListZpool (1.97s)
=== RUN TestRollback
--- PASS: TestRollback (5.31s)
=== RUN TestDiff
--- PASS: TestDiff (4.03s)
PASS
ok github.com/mistifyio/go-zfs 41.276s