only send with online boxes
This commit is contained in:
parent
9594fd7970
commit
7c309b850b
136
app.go
136
app.go
@ -578,92 +578,94 @@ func (a AppConfig) SendSnapshots() (err error) {
|
||||
}
|
||||
|
||||
for _, src := range a.Sources {
|
||||
for _, dest := range a.Destinations {
|
||||
if cfg.Box[dest.Box()].online {
|
||||
if *debugFlag {
|
||||
log.Printf("AppConfig.SendSnapshots : %s : Sending snapshots from %s to %s", a.Name, string(src), string(dest))
|
||||
}
|
||||
|
||||
var dLastSnapshot Snapshot
|
||||
dLastSnapshot, err = cfg.Box[dest.Box()].ZFSGetLastSnapshot(dest.Path() + "/" + src.Box() + "/" + src.Path())
|
||||
if err != nil && err.Error() == "no snapshot" {
|
||||
if cfg.Box[src.Box()].online {
|
||||
for _, dest := range a.Destinations {
|
||||
if cfg.Box[dest.Box()].online {
|
||||
if *debugFlag {
|
||||
log.Printf("AppConfig.SendSnapshots : %s : No snapshot for %s on %s", a.Name, string(src), dest.Box())
|
||||
log.Printf("AppConfig.SendSnapshots : %s : Sending snapshots from %s to %s", a.Name, string(src), string(dest))
|
||||
}
|
||||
|
||||
var sFirstSnapshot Snapshot
|
||||
sFirstSnapshot, err = cfg.Box[src.Box()].ZFSGetFirstSnapshot(src.Path())
|
||||
if err != nil {
|
||||
var dLastSnapshot Snapshot
|
||||
dLastSnapshot, err = cfg.Box[dest.Box()].ZFSGetLastSnapshot(dest.Path() + "/" + src.Box() + "/" + src.Path())
|
||||
if err != nil && err.Error() == "no snapshot" {
|
||||
if *debugFlag {
|
||||
log.Printf("AppConfig.SendSnapshots : %s : No snapshot for %s", a.Name, string(src))
|
||||
log.Printf("AppConfig.SendSnapshots : %s : No snapshot for %s on %s", a.Name, string(src), dest.Box())
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if *debugFlag {
|
||||
log.Printf("AppConfig.SendSnapshots : %s : Initializing snapshot on %s from %s", a.Name, dest.Box(), string(sFirstSnapshot))
|
||||
}
|
||||
_, err = cfg.Box[dest.Box()].SSHExec("ssh " + cfg.Box[src.Box()].User + "@" + src.Box() + " zfs send " + string(sFirstSnapshot) + " | zfs recv -F " + dest.Path() + "/" + src.Box() + "/" + src.Path())
|
||||
if err != nil {
|
||||
if *debugFlag {
|
||||
log.Printf("AppConfig.SendSnapshots : %s : Initializing snapshot on %s from %s failed (%s)", a.Name, dest.Box(), string(sFirstSnapshot), err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
var (
|
||||
sCurrSnapshot, sNextSnapshot Snapshot
|
||||
isLastSnapshot bool
|
||||
)
|
||||
sNextSnapshot = sFirstSnapshot
|
||||
isLastSnapshot, _ = cfg.Box[src.Box()].ZFSIsLastSnapshot(sNextSnapshot)
|
||||
if !isLastSnapshot {
|
||||
sCurrSnapshot = sNextSnapshot
|
||||
sNextSnapshot, err = cfg.Box[src.Box()].ZFSGetLastSnapshot(sNextSnapshot.Path())
|
||||
if *debugFlag {
|
||||
log.Printf("AppConfig.SendSnapshots : %s : Sending incrementally %s to %s", a.Name, string(sNextSnapshot), dest.Box())
|
||||
}
|
||||
if err != nil && err.Error() != "no snapshot" {
|
||||
return
|
||||
}
|
||||
_, err = cfg.Box[dest.Box()].SSHExec("ssh " + cfg.Box[src.Box()].User + "@" + src.Box() + " zfs send -I " + string(sCurrSnapshot) + " " + string(sNextSnapshot) + " | zfs recv -F " + dest.Path() + "/" + src.Box() + "/" + src.Path())
|
||||
var sFirstSnapshot Snapshot
|
||||
sFirstSnapshot, err = cfg.Box[src.Box()].ZFSGetFirstSnapshot(src.Path())
|
||||
if err != nil {
|
||||
if *debugFlag {
|
||||
log.Printf("AppConfig.SendSnapshots : %s : Sending snapshot on %s from %s failed (%s)", a.Name, dest.Box(), string(sNextSnapshot), err)
|
||||
log.Printf("AppConfig.SendSnapshots : %s : No snapshot for %s", a.Name, string(src))
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
if *debugFlag {
|
||||
log.Printf("AppConfig.SendSnapshots : %s : All snapshots sent for %s", a.Name, string(src))
|
||||
}
|
||||
|
||||
} else {
|
||||
if *debugFlag {
|
||||
log.Printf("AppConfig.SendSnapshots : %s : Last snapshot on %s is %s", a.Name, dest.Box(), string(dLastSnapshot))
|
||||
}
|
||||
var (
|
||||
sCurrSnapshot, sNextSnapshot Snapshot
|
||||
isLastSnapshot bool
|
||||
)
|
||||
sNextSnapshot = Snapshot(string(dLastSnapshot)[len(dest.Path())+len(src.Box())+2:])
|
||||
isLastSnapshot, _ = cfg.Box[src.Box()].ZFSIsLastSnapshot(sNextSnapshot)
|
||||
if !isLastSnapshot {
|
||||
sCurrSnapshot = sNextSnapshot
|
||||
sNextSnapshot, err = cfg.Box[src.Box()].ZFSGetLastSnapshot(sNextSnapshot.Path())
|
||||
if *debugFlag {
|
||||
log.Printf("AppConfig.SendSnapshots : %s : Sending incrementally %s to %s", a.Name, string(sNextSnapshot), dest.Box())
|
||||
log.Printf("AppConfig.SendSnapshots : %s : Initializing snapshot on %s from %s", a.Name, dest.Box(), string(sFirstSnapshot))
|
||||
}
|
||||
if err != nil && err.Error() != "no snapshot" {
|
||||
return
|
||||
}
|
||||
_, err = cfg.Box[dest.Box()].SSHExec("ssh " + cfg.Box[src.Box()].User + "@" + src.Box() + " zfs send -I " + string(sCurrSnapshot) + " " + string(sNextSnapshot) + " | zfs recv -F " + dest.Path() + "/" + src.Box() + "/" + src.Path())
|
||||
_, err = cfg.Box[dest.Box()].SSHExec("ssh " + cfg.Box[src.Box()].User + "@" + src.Box() + " zfs send " + string(sFirstSnapshot) + " | zfs recv -F " + dest.Path() + "/" + src.Box() + "/" + src.Path())
|
||||
if err != nil {
|
||||
if *debugFlag {
|
||||
log.Printf("AppConfig.SendSnapshots : %s : Sending snapshot on %s from %s failed (%s)", a.Name, dest.Box(), string(sNextSnapshot), err)
|
||||
log.Printf("AppConfig.SendSnapshots : %s : Initializing snapshot on %s from %s failed (%s)", a.Name, dest.Box(), string(sFirstSnapshot), err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
var (
|
||||
sCurrSnapshot, sNextSnapshot Snapshot
|
||||
isLastSnapshot bool
|
||||
)
|
||||
sNextSnapshot = sFirstSnapshot
|
||||
isLastSnapshot, _ = cfg.Box[src.Box()].ZFSIsLastSnapshot(sNextSnapshot)
|
||||
if !isLastSnapshot {
|
||||
sCurrSnapshot = sNextSnapshot
|
||||
sNextSnapshot, err = cfg.Box[src.Box()].ZFSGetLastSnapshot(sNextSnapshot.Path())
|
||||
if *debugFlag {
|
||||
log.Printf("AppConfig.SendSnapshots : %s : Sending incrementally %s to %s", a.Name, string(sNextSnapshot), dest.Box())
|
||||
}
|
||||
if err != nil && err.Error() != "no snapshot" {
|
||||
return
|
||||
}
|
||||
_, err = cfg.Box[dest.Box()].SSHExec("ssh " + cfg.Box[src.Box()].User + "@" + src.Box() + " zfs send -I " + string(sCurrSnapshot) + " " + string(sNextSnapshot) + " | zfs recv -F " + dest.Path() + "/" + src.Box() + "/" + src.Path())
|
||||
if err != nil {
|
||||
if *debugFlag {
|
||||
log.Printf("AppConfig.SendSnapshots : %s : Sending snapshot on %s from %s failed (%s)", a.Name, dest.Box(), string(sNextSnapshot), err)
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
if *debugFlag {
|
||||
log.Printf("AppConfig.SendSnapshots : %s : All snapshots sent for %s", a.Name, string(src))
|
||||
}
|
||||
|
||||
} else {
|
||||
if *debugFlag {
|
||||
log.Printf("AppConfig.SendSnapshots : %s : Last snapshot on %s is %s", a.Name, dest.Box(), string(dLastSnapshot))
|
||||
}
|
||||
var (
|
||||
sCurrSnapshot, sNextSnapshot Snapshot
|
||||
isLastSnapshot bool
|
||||
)
|
||||
sNextSnapshot = Snapshot(string(dLastSnapshot)[len(dest.Path())+len(src.Box())+2:])
|
||||
isLastSnapshot, _ = cfg.Box[src.Box()].ZFSIsLastSnapshot(sNextSnapshot)
|
||||
if !isLastSnapshot {
|
||||
sCurrSnapshot = sNextSnapshot
|
||||
sNextSnapshot, err = cfg.Box[src.Box()].ZFSGetLastSnapshot(sNextSnapshot.Path())
|
||||
if *debugFlag {
|
||||
log.Printf("AppConfig.SendSnapshots : %s : Sending incrementally %s to %s", a.Name, string(sNextSnapshot), dest.Box())
|
||||
}
|
||||
if err != nil && err.Error() != "no snapshot" {
|
||||
return
|
||||
}
|
||||
_, err = cfg.Box[dest.Box()].SSHExec("ssh " + cfg.Box[src.Box()].User + "@" + src.Box() + " zfs send -I " + string(sCurrSnapshot) + " " + string(sNextSnapshot) + " | zfs recv -F " + dest.Path() + "/" + src.Box() + "/" + src.Path())
|
||||
if err != nil {
|
||||
if *debugFlag {
|
||||
log.Printf("AppConfig.SendSnapshots : %s : Sending snapshot on %s from %s failed (%s)", a.Name, dest.Box(), string(sNextSnapshot), err)
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Code generated by version.sh (@generated) DO NOT EDIT.
|
||||
package main
|
||||
var githash = "23d7d90"
|
||||
var buildstamp = "2022-06-17_14:07:22"
|
||||
var commits = "40"
|
||||
var version = "23d7d90-b40 - 2022-06-17_14:07:22"
|
||||
var githash = "9594fd7"
|
||||
var buildstamp = "2022-06-17_14:11:08"
|
||||
var commits = "41"
|
||||
var version = "9594fd7-b41 - 2022-06-17_14:11:08"
|
||||
|
Loading…
Reference in New Issue
Block a user