zfs: implement ZFSSend

This commit is contained in:
Christian Schwarz
2017-05-07 12:18:54 +02:00
parent 1a92717894
commit 030bd7affe
3 changed files with 109 additions and 0 deletions

View File

@ -102,3 +102,19 @@ func ZFSList(properties []string, zfsArgs ...string) (res [][]string, err error)
}
return
}
func ZFSSend(fs DatasetPath, from, to *FilesystemVersion) (stream io.Reader, err error) {
args := make([]string, 0)
args = append(args, "send")
if to == nil { // Initial
args = append(args, from.ToAbsPath(fs))
} else {
args = append(args, "-i", from.ToAbsPath(fs), to.ToAbsPath(fs))
}
stream, err = NewForkReader(ZFS_BINARY, args...)
return
}