Compare commits

..

No commits in common. "c93aa200b4e108d1ef4dcab024c6bf748915c211" and "d895b930f701072fc3092676adf09133fa3a890f" have entirely different histories.

2 changed files with 20 additions and 44 deletions

56
box.go
View File

@ -18,10 +18,6 @@ type Box struct {
}
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)
}
err = b.SnapshotInitialize()
if err != nil {
return
@ -30,6 +26,10 @@ func (b *Box) ZFSTakeSnapshot(schedule, path string) (err error) {
b.zfs.M.Lock()
defer b.zfs.M.Unlock()
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])
_, err = b.ssh.exec("zfs snapshot " + path + "@" + name)
@ -45,10 +45,6 @@ func (b *Box) ZFSTakeSnapshot(schedule, path string) (err error) {
}
func (b *Box) ZFSGetLastSnapshot(path string) (last Snapshot, err error) {
if *debugFlag {
log.Printf("Box.ZFSGetLastSnapshot : %s : Start %s (%d snapshots)", b.Name, path, len(b.zfs.SnapshotList))
}
err = b.SnapshotInitialize()
if err != nil {
return
@ -57,6 +53,10 @@ func (b *Box) ZFSGetLastSnapshot(path string) (last Snapshot, err error) {
b.zfs.M.Lock()
defer b.zfs.M.Unlock()
if *debugFlag {
log.Printf("Box.ZFSGetLastSnapshot : %s : Start %s (%d snapshots)", b.Name, path, len(b.zfs.SnapshotList))
}
for _, v := range b.zfs.SnapshotList {
if v.Path() == path {
last = v
@ -69,10 +69,6 @@ func (b *Box) ZFSGetLastSnapshot(path string) (last Snapshot, err error) {
}
func (b *Box) ZFSIsLastSnapshot(src Snapshot) (is bool, err error) {
if *debugFlag {
log.Printf("Box.ZFSIsLastSnapshot : %s : Start %s", b.Name, string(src))
}
err = b.SnapshotInitialize()
if err != nil {
return
@ -98,10 +94,6 @@ func (b *Box) ZFSIsLastSnapshot(src Snapshot) (is bool, err error) {
}
func (b *Box) ZFSGetFirstSnapshot(path string) (first Snapshot, err error) {
if *debugFlag {
log.Printf("SSHConfig.getFirstSnapshot : %s : Start %s", b.Name, path)
}
err = b.SnapshotInitialize()
if err != nil {
return
@ -110,6 +102,10 @@ func (b *Box) ZFSGetFirstSnapshot(path string) (first Snapshot, err error) {
b.zfs.M.Lock()
defer b.zfs.M.Unlock()
if *debugFlag {
log.Printf("SSHConfig.getFirstSnapshot : Start %s:%s", b.Name, path)
}
for _, v := range b.zfs.SnapshotList {
if v.Path() == path {
first = v
@ -121,10 +117,6 @@ func (b *Box) ZFSGetFirstSnapshot(path string) (first Snapshot, err error) {
}
func (b *Box) ZFSGetNextSnapshot(src Snapshot) (next Snapshot, err error) {
if *debugFlag {
log.Printf("Box.ZFSGetNextSnapshot : %s : Start %s", b.Name, string(src))
}
err = b.SnapshotInitialize()
if err != nil {
return
@ -133,6 +125,10 @@ func (b *Box) ZFSGetNextSnapshot(src Snapshot) (next Snapshot, err error) {
b.zfs.M.Lock()
defer b.zfs.M.Unlock()
if *debugFlag {
log.Printf("Box.ZFSGetNextSnapshot : Start %s:%s", b.Name, string(src))
}
for id, v := range b.zfs.SnapshotList {
if v == src {
if len(b.zfs.SnapshotList) > id+1 {
@ -154,10 +150,6 @@ func (b *Box) ZFSGetNextSnapshot(src Snapshot) (next Snapshot, err error) {
}
func (b *Box) ZFSUpdateSnapshotList() (err error) {
if *debugFlag {
log.Printf("Box.ZFSUpdateSnapshotList : %s : Start", b.Name)
}
b.zfs.M.Lock()
if b.zfs.SnapshotDeleted || b.zfs.SnapshotAdded {
b.zfs.SnapshotInitialized = false
@ -169,10 +161,6 @@ func (b *Box) ZFSUpdateSnapshotList() (err error) {
}
func (b *Box) ZFSGetSnapshotList() (snaps []Snapshot, err error) {
if *debugFlag {
log.Printf("Box.ZFSGetSnapshotList : %s : Start", b.Name)
}
err = b.SnapshotInitialize()
if err != nil {
return
@ -230,10 +218,6 @@ func (b *Box) SnapshotInitialize() (err error) {
}
func (b *Box) ZFSUpdateList() (err error) {
if *debugFlag {
log.Printf("Box.ZFSUpdateList : %s : Start", b.Name)
}
b.zfs.M.Lock()
if b.zfs.ZFSDeleted || b.zfs.ZFSAdded {
b.zfs.ZFSInitialized = false
@ -245,10 +229,6 @@ func (b *Box) ZFSUpdateList() (err error) {
}
func (b *Box) ZFSIsZFS(path string) bool {
if *debugFlag {
log.Printf("Box.ZFSIsZFS : %s : Start %s", b.Name, path)
}
err := b.ZFSInitialize()
if err != nil {
return false
@ -265,10 +245,6 @@ func (b *Box) ZFSIsZFS(path string) bool {
}
func (b *Box) ZFSCreateZFS(path string) (err error) {
if *debugFlag {
log.Printf("Box.ZFSCreateZFS : %s : Start %s", b.Name, path)
}
err = b.ZFSInitialize()
if err != nil {
return

View File

@ -1,6 +1,6 @@
// Code generated by version.sh (@generated) DO NOT EDIT.
package main
var githash = "d895b93"
var buildstamp = "2021-11-14_10:09:45"
var commits = "23"
var version = "d895b93-b23 - 2021-11-14_10:09:45"
var githash = "0d3981e"
var buildstamp = "2021-11-14_09:46:54"
var commits = "22"
var version = "0d3981e-b22 - 2021-11-14_09:46:54"