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:
27
dump.go
27
dump.go
@@ -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"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user