3
0
mirror of https://kolaente.dev/konrad/docker-db-backup.git synced 2026-01-10 02:50:08 +01:00

Add dump helpers

This commit is contained in:
kolaente
2021-08-18 21:29:17 +02:00
parent 79f6c5cfad
commit 5ec093fbf6
4 changed files with 128 additions and 1 deletions

27
dump.go
View File

@@ -1,6 +1,9 @@
package main
import "github.com/docker/docker/api/types"
import (
"github.com/docker/docker/api/types"
"strings"
)
type Dumper interface {
Dump() error
@@ -18,3 +21,25 @@ func NewDumperFromContainer(container *types.ContainerJSON) Dumper {
return nil
}
func dumpAllDatabases() error {
lock.Lock()
defer lock.Unlock()
for _, dumper := range store {
err := dumper.Dump()
if err != nil {
return err
}
}
return nil
}
func getDumpFilename(containerName string) string {
if strings.HasPrefix(containerName, "/") {
containerName = strings.TrimPrefix(containerName, "/")
}
return config.fullCurrentBackupPath + containerName + ".sql"
}