Skip to content

Function SendSnapshotIncremental #58

@icarbajovallejo

Description

@icarbajovallejo

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 !

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions