implement automatic snapshotting feature

This commit is contained in:
Christian Schwarz
2017-07-01 20:28:46 +02:00
parent 8c8a6ee905
commit 655b3ab55f
5 changed files with 211 additions and 6 deletions
+23
View File
@@ -204,3 +204,26 @@ func ZFSDestroy(dataset string) (err error) {
return
}
func ZFSSnapshot(fs DatasetPath, name string, recursive bool) (err error) {
snapname := fmt.Sprintf("%s@%s", fs.ToString(), name)
cmd := exec.Command(ZFS_BINARY, "snapshot", snapname)
stderr := bytes.NewBuffer(make([]byte, 0, 1024))
cmd.Stderr = stderr
if err = cmd.Start(); err != nil {
return err
}
if err = cmd.Wait(); err != nil {
err = ZFSError{
Stderr: stderr.Bytes(),
WaitErr: err,
}
}
return
}