replace zfsnap for snapshot taking
This commit is contained in:
23
box.go
23
box.go
@@ -1,11 +1,15 @@
|
||||
package main
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
)
|
||||
|
||||
type Box struct {
|
||||
Addr string `json:"addr"`
|
||||
User string `json:"user"`
|
||||
Key string `json:"key"`
|
||||
Name string `json:"-"`
|
||||
ssh *SSHConfig
|
||||
}
|
||||
|
||||
@@ -45,14 +49,15 @@ func (b *Box) ZFSCreateZFS(path string) (err error) {
|
||||
return b.ssh.createZFS(path)
|
||||
}
|
||||
|
||||
func (b *Box) GetTime() time.Time {
|
||||
return b.ssh.now
|
||||
}
|
||||
|
||||
func (b *Box) UpdateTime() (err error) {
|
||||
return b.ssh.getTime()
|
||||
}
|
||||
|
||||
func (b *Box) SSHExec(cmd string) (err error) {
|
||||
return b.ssh.exec(cmd)
|
||||
}
|
||||
|
||||
func (b *Box) ZFSTakeSnapshot(schedule, path string) (err error) {
|
||||
if *debugFlag {
|
||||
log.Printf("Box.ZFSTakeSnapshot : %s : taking snapshot on %s for %s", b.Name, path, schedule)
|
||||
}
|
||||
timestamp := cfg.Now.Format("2006-01-02_15.04.05")
|
||||
name := fmt.Sprintf("%s-%s--%s", schedule, timestamp, cfg.Zfsnap[schedule])
|
||||
return b.ssh.exec("zfs snapshot " + path + "@" + name)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user