package main import ( "fmt" "log" ) type Box struct { Addr string `json:"addr"` User string `json:"user"` Key string `json:"key"` Name string `json:"-"` ssh *SSHConfig } func (b *Box) ZFSGetLastSnapshot(path string) (s Snapshot, err error) { return b.ssh.getLastSnapshot(path) } func (b *Box) ZFSIsLastSnapshot(s Snapshot) bool { return b.ssh.isLastSnapshot(s) } func (b *Box) ZFSGetFirstSnapshot(path string) (s Snapshot, err error) { return b.ssh.getFirstSnapshot(path) } func (b *Box) ZFSGetNextSnapshot(src Snapshot) (next Snapshot, err error) { return b.ssh.getNextSnapshot(src) } func (b *Box) ZFSUpdateSnapshotList() (err error) { return b.ssh.getSnapshotList() } func (b *Box) ZFSGetSnapshotList() []Snapshot { return b.ssh.snapshot } func (b *Box) ZFSUpdateList() (err error) { return b.ssh.getZFSList() } func (b *Box) ZFSIsZFS(path string) bool { return b.ssh.isZFS(path) } func (b *Box) ZFSCreateZFS(path string) (err error) { return b.ssh.createZFS(path) } 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) }