Skip to content

Config file issues #406

@kbrohkahn

Description

@kbrohkahn

I'm trying to apply a config file using the following template, but I've been unable to do so with a variety of configurations.

  mysql-backup:
    image: databack/mysql-backup
    container_name: mysql-backup
    restart: unless-stopped
    environment:
      DB_DUMP_TARGET: /db
      RUN_ONCE: true

      DB_SERVER: mariadb
      DB_PORT: 3306
      TZ: America/New_York
      DB_DUMP_CONFIG: /mysql-backup.yaml
    volumes:
      - ./backups:/db
      - ./mysql-backup.yaml:/mysql-backup.yaml
    command: dump
    networks:
      mariadb:
    depends_on:
      - mariadb

My mysql-backup.yaml file contains the following:

spec:
  database:
    server: mariadb
    port: 3306
    credentials:
      username: backup
      password: <password>

But the logs show an "access denied" as if neither the user nor password has been applied.

time="2025-02-20T17:37:49Z" level=fatal msg="error running command: error running command: error running dump: failed to list database schemas: could not get schemas: Error 1045 (28000): Access denied for user ''@'172.25.0.3' (using password: NO)"

If I instead apply the config file via command per the docs like

command: dump --config=/mysql-backup.yaml

I get this "unknown flag" error

time="2025-02-20T17:42:15Z" level=fatal msg="unknown flag: --config"

If I change the paramater from --config to --config-file as in the following

command: dump --config-file=/mysql-backup.yaml

I instead get the following runtime error:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xe6bc22]
goroutine 1 [running]:
github.com/databacker/mysql-backup/cmd.dumpCmd.func2(0xc000294308, {0x108b511?, 0x4?, 0x108b515?})
	/src/mysql-backup/cmd/dump.go:137 +0x782
github.com/spf13/cobra.(*Command).execute(0xc000294308, {0xc000249610, 0x1, 0x1})
	/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:983 +0xaca
github.com/spf13/cobra.(*Command).ExecuteC(0xc000294008)
	/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:1115 +0x3ff
github.com/spf13/cobra.(*Command).Execute(...)
	/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:1039
github.com/databacker/mysql-backup/cmd.Execute()
	/src/mysql-backup/cmd/root.go:273 +0x65
main.main()
	/src/mysql-backup/main.go:8 +0xf

Everything works when I set the DB_USER and DB_PASS environmental variables, but I'd like to avoid these.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions