fix zfs send for expired snapshots

This commit is contained in:
shoopea 2023-09-10 18:38:53 +02:00
parent 3b1d0fc850
commit 2ca0695a1f
3 changed files with 19 additions and 11 deletions

19
box.go
View File

@ -198,13 +198,18 @@ func TransferDirectZfs(from, to Addr) error {
}
fromFromSnapshotId := -1
lastToSnapshot := toSnapshots[len(toSnapshots)-1]
log.WithFields(log.Fields{"from": from, "to": to}).Debugf("searching last snapshot %s", lastToSnapshot.String())
for id, v := range fromSnapshots {
if v.name == lastToSnapshot.name {
fromFromSnapshotId = id
log.WithFields(log.Fields{"from": from, "to": to}).Debugf("found %s", v.String())
fromFromSnapshotId := len(fromSnapshots)
fromToSnapshotId := -1
for fromFromSnapshotId >= 0 {
fromFromSnapshotId = fromFromSnapshotId - 1
fromToSnapshotId = len(toSnapshots)
for fromToSnapshotId >= 0 {
fromToSnapshotId = fromToSnapshotId - 1
if fromSnapshots[fromFromSnapshotId].name == toSnapshots[fromToSnapshotId].name {
break
}
}
if fromToSnapshotId >= 0 {
break
}
}

View File

@ -1,7 +1,7 @@
// Code generated by version.sh (@generated) DO NOT EDIT.
package main
var githash = "e7ed6cb"
var githash = "3b1d0fc"
var branch = "master"
var buildstamp = "2023-08-22_11:08:53"
var commits = "85"
var version = "e7ed6cb-b85 - 2023-08-22_11:08:53"
var buildstamp = "2023-09-10_16:35:29"
var commits = "86"
var version = "3b1d0fc-b86 - 2023-09-10_16:35:29"

3
zfs.go
View File

@ -311,6 +311,9 @@ func (fs *ZfsFs) AddSnapshot(s *ZfsSnapshot) error {
}
func (fs *ZfsFs) ValidSnapshots() []*ZfsSnapshot {
log.WithFields(log.Fields{"box": fs.zfs.box.name, "fs": fs.path}).Debugf("starting")
defer log.WithFields(log.Fields{"box": fs.zfs.box.name, "fs": fs.path}).Debugf("done")
tab := make([]*ZfsSnapshot, 0)
for _, s := range fs.snapshots {