mirror of
https://kolaente.dev/konrad/docker-db-backup.git
synced 2026-01-10 03:00:08 +01:00
feat: add cron schedule
This commit is contained in:
42
main.go
42
main.go
@@ -2,6 +2,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -10,24 +11,29 @@ func main() {
|
|||||||
log.Fatalf("Could not create client: %s", err)
|
log.Fatalf("Could not create client: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
updateFullBackupPath()
|
for {
|
||||||
|
updateFullBackupPath()
|
||||||
|
|
||||||
containers, err := getContainers(c)
|
containers, err := getContainers(c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Could not get containers: %s", err)
|
log.Fatalf("Could not get containers: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
storeContainers(c, containers)
|
||||||
|
|
||||||
|
err = cleanupOldBackups()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("Could not clean old backups: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
err = dumpAllDatabases(c)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("Could not dump databases: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Println("Done.")
|
||||||
|
log.Printf("Sleeping for %s\n", config.Interval)
|
||||||
|
|
||||||
|
time.Sleep(config.Interval)
|
||||||
}
|
}
|
||||||
|
|
||||||
storeContainers(c, containers)
|
|
||||||
|
|
||||||
err = cleanupOldBackups()
|
|
||||||
if err != nil {
|
|
||||||
log.Fatalf("Could not clean old backups: %s", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
err = dumpAllDatabases(c)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatalf("Could not dump databases: %s", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Cron
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user