Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Config file issues #406

Open
kbrohkahn opened this issue Feb 20, 2025 · 4 comments
Open

Config file issues #406

kbrohkahn opened this issue Feb 20, 2025 · 4 comments

Comments

@kbrohkahn
Copy link

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.

@deitch
Copy link
Collaborator

deitch commented Feb 21, 2025

This sounds like several distinct issues with reconciling env vars vs CLI flags vs documentation:

  • config file flag: --config does not work, --config-file does, where the documentation clearly stats --config
  • possibly DB_DUMP_CONFIG is ignored; unclear if it is not reading the config file, or reading it and not getting the DB user/pass
  • SIGSEGV error when the config file is read

Is that a fair summary?

@deitch
Copy link
Collaborator

deitch commented Feb 21, 2025

Can you also try DB_CONFIG_FILE, which is what would line up with --config-file, and see if that gives the same results? Based on what I see in the source, that would be accurate, and the documentation is incorrect. Hopefully that will give the same crash error, which we then can address.

Actually, the docs are inconsistent. Most of the configuration.md describes DB_DUMP_CONFIG and --config, but 2 locations in README.md show --config-file. In any case, please check.

@kbrohkahn
Copy link
Author

Yup using DB_CONFIG_FILE had pretty much the same error.

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xe6bc22]
goroutine 1 [running]:
ithub.com/dagtabacker/mysql-backup/cmd.dumpCmd.func2(0xc000288308, {0x108b511?, 0x4?, 0x108b515?})
	/src/mysql-backup/cmd/dump.go:137 +0x782
github.com/spf13/cobra.(*Command).execute(0xc000288308, {0x196e780, 0x0, 0x0})
	/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:983 +0xaca
github.com/spf13/cobra.(*Command).ExecuteC(0xc000288008)
	/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

Looks like you were able to fix the docs do reflect the correct parameter/env variable name, so now the only issue is the error indicating the nil pointer when using the config file.

@deitch
Copy link
Collaborator

deitch commented Feb 22, 2025

A patch went in yesterday to address specific issues there. Since you are using the container, try the tag
databack/mysql-backup:928706228c637524d8cd48d08c382c4c590cd089 and report if that works, or any errors?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants