zfsCopyIncremental to send/receive incremental snapshots
This commit is contained in:
parent
6c6cb7edc8
commit
542d2f96f6
40
cmd/utils.go
40
cmd/utils.go
@ -268,6 +268,46 @@ func zfsCopy(src string, dest string) error {
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
func zfsCopyIncremental(firstsnap string, lastsnap string, dest string) error {
|
||||||
|
// First, declare sending process & pipe
|
||||||
|
cmd_send := exec.Command("zfs", "send", "-i", firstsnap, lastsnap)
|
||||||
|
stdout_send, err := cmd_send.StdoutPipe()
|
||||||
|
if err != nil {
|
||||||
|
return errors.New(fmt.Sprintf("Error: %v\n", err))
|
||||||
|
}
|
||||||
|
|
||||||
|
// then declare receiving process & pipe
|
||||||
|
cmd_recv := exec.Command("zfs", "receive", dest)
|
||||||
|
stdin_recv, err := cmd_recv.StdinPipe()
|
||||||
|
if err != nil {
|
||||||
|
return errors.New(fmt.Sprintf("Error: %v\n", err))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Copy data in a go routine
|
||||||
|
go io.Copy(stdin_recv, stdout_send)
|
||||||
|
|
||||||
|
// then start processes and wait for finish
|
||||||
|
if err := cmd_recv.Start(); err != nil {
|
||||||
|
return errors.New(fmt.Sprintf("Error starting receive process: %v\n", err))
|
||||||
|
}
|
||||||
|
//fmt.Printf("DEBUG: Start \"zfs send %s\"\n", dsconf)
|
||||||
|
if err := cmd_send.Start(); err != nil {
|
||||||
|
return errors.New(fmt.Sprintf("Error starting send process: %v\n", err))
|
||||||
|
}
|
||||||
|
|
||||||
|
//fmt.Printf("DEBUG: Wait for zfs send to finish\n")
|
||||||
|
if err := cmd_send.Wait(); err != nil {
|
||||||
|
return errors.New(fmt.Sprintf("send halted with: %v\n", err))
|
||||||
|
}
|
||||||
|
//fmt.Printf("DEBUG: Wait for zfs recv to finish\n")
|
||||||
|
if err := cmd_recv.Wait(); err != nil {
|
||||||
|
return errors.New(fmt.Sprintf("receive halted with: %v\n", err))
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
*
|
*
|
||||||
* rc.conf management
|
* rc.conf management
|
||||||
|
Loading…
Reference in New Issue
Block a user