From f34f219e6a9d148baf682988523306b3e570fbdf Mon Sep 17 00:00:00 2001 From: suurkivi <136639517+suurkivi@users.noreply.github.com> Date: Wed, 16 Oct 2024 09:56:34 -0700 Subject: [PATCH] upgrade backup code --- cmd/z2-backup/main.go | 1 - go.mod | 2 +- go.sum | 2 ++ routes.go | 22 ++++++---------------- 4 files changed, 9 insertions(+), 18 deletions(-) diff --git a/cmd/z2-backup/main.go b/cmd/z2-backup/main.go index b9d8337..512ab9f 100644 --- a/cmd/z2-backup/main.go +++ b/cmd/z2-backup/main.go @@ -20,7 +20,6 @@ func run() error { return errors.Wrap(err, "check config") } - // TODO: reuse this message parsing code for both backup paths err = restic.Run(&opts.Backup, backupPath, restic.LogMessages(func(msg string) error { fmt.Println(msg) return nil diff --git a/go.mod b/go.mod index 7312aa5..4a0a954 100644 --- a/go.mod +++ b/go.mod @@ -54,7 +54,7 @@ require ( github.com/kr/text v0.2.0 // indirect github.com/leodido/go-urn v1.4.0 // indirect github.com/mattn/go-isatty v0.0.20 // indirect - github.com/minor-industries/backup v0.0.0-20241016163152-757b19a4d47b // indirect + github.com/minor-industries/backup v0.0.0-20241016165138-a90733379ccb // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/pelletier/go-toml/v2 v2.2.3 // indirect diff --git a/go.sum b/go.sum index f25a839..df82751 100644 --- a/go.sum +++ b/go.sum @@ -94,6 +94,8 @@ github.com/minor-industries/backup v0.0.0-20241015171350-e41b52e4df2d h1:hd5YuEp github.com/minor-industries/backup v0.0.0-20241015171350-e41b52e4df2d/go.mod h1:RggHPqXbHhTxy+rcEwfP3zv1CewnvY7nVFsI3Fqv7KA= github.com/minor-industries/backup v0.0.0-20241016163152-757b19a4d47b h1:/4CGoULSeyUENj+DWYjigDFwpN1VNCBcc1nwhGRXibk= github.com/minor-industries/backup v0.0.0-20241016163152-757b19a4d47b/go.mod h1:RggHPqXbHhTxy+rcEwfP3zv1CewnvY7nVFsI3Fqv7KA= +github.com/minor-industries/backup v0.0.0-20241016165138-a90733379ccb h1:NeXn5YRJCg9mh7nAKK/OvmbbCWl8mQmdPQ4cqcs2qFk= +github.com/minor-industries/backup v0.0.0-20241016165138-a90733379ccb/go.mod h1:RggHPqXbHhTxy+rcEwfP3zv1CewnvY7nVFsI3Fqv7KA= github.com/minor-industries/calendar v0.0.2 h1:z0HSSbS/dC4NktGuWPNYtV7/EMhjaN9nLB0nVxMGIyY= github.com/minor-industries/calendar v0.0.2/go.mod h1:ObostlqefZmRtphanxopvWSVW2dhQ2KiJCqC5jZvQZc= github.com/minor-industries/rtgraph v0.0.20 h1:/H0xAETtSck3pl7tzNHzeGgykGfVPvl8rxWrsPm+Er0= diff --git a/routes.go b/routes.go index 95dce6b..1c24c1e 100644 --- a/routes.go +++ b/routes.go @@ -210,22 +210,12 @@ func setupRoutes( return } - for i, target := range opts.Backup.Targets { - _ = send("info", "") - _ = send("info", fmt.Sprintf("starting backup[%d]", i)) - err = restic.BackupOne(&opts.Backup, &target, backupPath, restic.QuantizeFilter(func(msg any) error { - switch msg := msg.(type) { - case restic.ResticStatus: - _ = send("info", fmt.Sprintf(" progress: %.1f%%", msg.PercentDone*100)) - case restic.ResticSummary: - _ = send("info", fmt.Sprintf("backup[%d] complete", i)) - } - return nil - })) - - if err != nil { - _ = send("server-error", errors.Wrap(err, "backup one").Error()) - } + if err := restic.Run(&opts.Backup, backupPath, restic.LogMessages(func(msg string) error { + _ = send("info", msg) + return nil + })); err != nil { + _ = send("server-error", errors.Wrap(err, "run backup").Error()) + return } })