Skip to content

Commit

Permalink
upgrade backup code
Browse files Browse the repository at this point in the history
  • Loading branch information
suurkivi committed Oct 16, 2024
1 parent e0ff00e commit f34f219
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 18 deletions.
1 change: 0 additions & 1 deletion cmd/z2-backup/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
22 changes: 6 additions & 16 deletions routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
})

Expand Down

0 comments on commit f34f219

Please sign in to comment.