1
0
mirror of https://github.com/offen/docker-volume-backup.git synced 2025-11-23 21:44:40 +02:00

Ensure end time is recorded for unsuccessful runs too (#62)

* Ensure end time is also recorded for unsuccessful runs

* Clean up integration tests
This commit is contained in:
Frederik Ring
2022-02-13 09:41:36 +01:00
committed by GitHub
parent 0e248010a8
commit 3e17d1b123
6 changed files with 53 additions and 50 deletions

View File

@@ -88,8 +88,6 @@ func main() {
s.must(s.encryptBackup())
s.must(s.copyBackup())
s.must(s.pruneOldBackups())
s.stats.EndTime = time.Now()
s.stats.TookTime = s.stats.EndTime.Sub(s.stats.EndTime)
}
// script holds all the stateful information required to orchestrate a
@@ -191,8 +189,6 @@ type Config struct {
WebdavPassword string `split_words:"true"`
}
var msgBackupFailed = "backup run failed"
// newScript creates all resources needed for the script to perform actions against
// remote resources like the Docker engine or remote storage locations. All
// reading from env vars or other configuration sources is expected to happen
@@ -214,6 +210,12 @@ func newScript() (*script, error) {
},
}
s.registerHook(hookLevelPlumbing, func(error) error {
s.stats.EndTime = time.Now()
s.stats.TookTime = s.stats.EndTime.Sub(s.stats.EndTime)
return nil
})
if err := envconfig.Process("", s.c); err != nil {
return nil, fmt.Errorf("newScript: failed to process configuration values: %w", err)
}