more debug
This commit is contained in:
parent
efeb3a0e66
commit
c93aa200b4
56
box.go
56
box.go
@ -18,6 +18,10 @@ 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
|
||||
@ -26,10 +30,6 @@ 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,6 +45,10 @@ 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
|
||||
@ -53,10 +57,6 @@ 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,6 +69,10 @@ 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
|
||||
@ -94,6 +98,10 @@ 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
|
||||
@ -102,10 +110,6 @@ 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
|
||||
@ -117,6 +121,10 @@ 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
|
||||
@ -125,10 +133,6 @@ 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 {
|
||||
@ -150,6 +154,10 @@ 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
|
||||
@ -161,6 +169,10 @@ 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
|
||||
@ -218,6 +230,10 @@ 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
|
||||
@ -229,6 +245,10 @@ 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
|
||||
@ -245,6 +265,10 @@ 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
|
||||
|
Loading…
Reference in New Issue
Block a user