mirror of
https://kolaente.dev/konrad/docker-db-backup.git
synced 2026-01-10 02:50:08 +01:00
feat: add support for labels to discover additional containers
This commit is contained in:
6
dump.go
6
dump.go
@@ -6,6 +6,8 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
const containerLabelName = `de.kolaente.db-backup`
|
||||
|
||||
type Dumper interface {
|
||||
Dump(c *client.Client) error
|
||||
}
|
||||
@@ -13,11 +15,11 @@ type Dumper interface {
|
||||
func NewDumperFromContainer(container *types.ContainerJSON) Dumper {
|
||||
|
||||
// Containers contain the tags, therefore we need to check them one by one
|
||||
if strings.HasPrefix(container.Config.Image, "mysql") || strings.HasPrefix(container.Config.Image, "mariadb") {
|
||||
if strings.HasPrefix(container.Config.Image, "mysql") || strings.HasPrefix(container.Config.Image, "mariadb") || container.Config.Labels[containerLabelName] == "mysql" {
|
||||
return NewMysqlDumper(container)
|
||||
}
|
||||
|
||||
if strings.HasPrefix(container.Config.Image, "postgres") {
|
||||
if strings.HasPrefix(container.Config.Image, "postgres") || container.Config.Labels[containerLabelName] == "postgres" {
|
||||
return NewPostgresDumper(container)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user