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 fromFromSnapshotId := len(fromSnapshots)
lastToSnapshot := toSnapshots[len(toSnapshots)-1] fromToSnapshotId := -1
log.WithFields(log.Fields{"from": from, "to": to}).Debugf("searching last snapshot %s", lastToSnapshot.String()) for fromFromSnapshotId >= 0 {
for id, v := range fromSnapshots { fromFromSnapshotId = fromFromSnapshotId - 1
if v.name == lastToSnapshot.name { fromToSnapshotId = len(toSnapshots)
fromFromSnapshotId = id for fromToSnapshotId >= 0 {
log.WithFields(log.Fields{"from": from, "to": to}).Debugf("found %s", v.String()) fromToSnapshotId = fromToSnapshotId - 1
if fromSnapshots[fromFromSnapshotId].name == toSnapshots[fromToSnapshotId].name {
break
}
}
if fromToSnapshotId >= 0 {
break break
} }
} }

View File

@ -1,7 +1,7 @@
// Code generated by version.sh (@generated) DO NOT EDIT. // Code generated by version.sh (@generated) DO NOT EDIT.
package main package main
var githash = "e7ed6cb" var githash = "3b1d0fc"
var branch = "master" var branch = "master"
var buildstamp = "2023-08-22_11:08:53" var buildstamp = "2023-09-10_16:35:29"
var commits = "85" var commits = "86"
var version = "e7ed6cb-b85 - 2023-08-22_11:08:53" 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 { 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) tab := make([]*ZfsSnapshot, 0)
for _, s := range fs.snapshots { for _, s := range fs.snapshots {