From f36e7da82407252bfaaf061304ebed5c7b3af0b6 Mon Sep 17 00:00:00 2001 From: shoopea Date: Wed, 7 Sep 2022 22:21:03 +0800 Subject: [PATCH] change box addr for zfs send --- app.go | 6 +++--- box.go | 5 +++++ version.go | 8 ++++---- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/app.go b/app.go index d9a29b0..7a0d565 100644 --- a/app.go +++ b/app.go @@ -604,7 +604,7 @@ func (a AppConfig) SendSnapshots() (err error) { 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()) + _, err = cfg.Box[dest.Box()].SSHExec("ssh " + cfg.Box[src.Box()].User + "@" + cfg.Box[src.Box()].Host() + " 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) @@ -627,7 +627,7 @@ func (a AppConfig) SendSnapshots() (err error) { 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 + "@" + cfg.Box[src.Box()].Host() + " 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) @@ -658,7 +658,7 @@ func (a AppConfig) SendSnapshots() (err error) { 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 + "@" + cfg.Box[src.Box()].Host() + " 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) diff --git a/box.go b/box.go index b132993..c7545bb 100644 --- a/box.go +++ b/box.go @@ -416,3 +416,8 @@ func (b *Box) SSHExec(cmd string) (buf *bytes.Buffer, err error) { buf, err = b.ssh.exec(cmd) return } + +func (b *Box) Host() string { + s := strings.Split(string(b.Addr), `:`) + return s[0] +} diff --git a/version.go b/version.go index 24a534a..b1ccaeb 100644 --- a/version.go +++ b/version.go @@ -1,6 +1,6 @@ // Code generated by version.sh (@generated) DO NOT EDIT. package main -var githash = "fcc9fa3" -var buildstamp = "2022-06-19_04:33:26" -var commits = "50" -var version = "fcc9fa3-b50 - 2022-06-19_04:33:26" +var githash = "8a6fced" +var buildstamp = "2022-09-07_14:20:27" +var commits = "51" +var version = "8a6fced-b51 - 2022-09-07_14:20:27"