Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function SendSnapshotIncremental #58

Open
icarbajovallejo opened this issue May 23, 2017 · 2 comments
Open

Function SendSnapshotIncremental #58

icarbajovallejo opened this issue May 23, 2017 · 2 comments

Comments

@icarbajovallejo
Copy link

icarbajovallejo commented May 23, 2017

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 !

@joshie
Copy link
Member

joshie commented May 23, 2017

Making the pull request would be the best path forward.

@icarbajovallejo
Copy link
Author

=== 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants