Default config file `.grafana-backup.json` not found
Closed this issue · 3 comments
I experienced an issue similar to #116 before realizing that the tool was failing to read config from .grafana-backup.json
.
- The tool was installed with
pip install grafana-backup==1.2.5
. - OS: Debian
The file .grafana-backup.json
exists in the current working directory.
$ ls .grafana-backup.json
.grafana-backup.json
Content of .grafana-backup.json
:
{
"general": {
"debug": true,
"verify_ssl": true,
"backup_dir": "_OUTPUT_"
},
"grafana": {
"url": "http://grafana:3000",
"token": "<token>"
}
}
When running the following command, I observed that the tool is not using the Grafana URL defined in the config file (it uses localhost
instead):
$ ~/.local/bin/grafana-backup save
[Pre-Check] grafana health check: http://localhost:3000/api/health
[DEBUG] resp status: 200
[DEBUG] resp body: {'commit': 'cf0a135595', 'database': 'ok', 'version': '9.4.3'}
[Pre-Check] grafana auth check: http://localhost:3000/api/auth/keys
[DEBUG] resp status: 401
[DEBUG] resp body: {'message': 'Unauthorized'}
server status is not ok: {'message': 'Unauthorized'}
Specifying the location of this config file works:
$ ~/.local/bin/grafana-backup save --config .grafana-backup.json
[Pre-Check] grafana health check: http://grafana:3000/api/health
[DEBUG] resp status: 200
[DEBUG] resp body: {'commit': 'cf0a135595', 'database': 'ok', 'version': '9.4.3'}
[Pre-Check] grafana auth check: http://grafana:3000/api/auth/keys
[DEBUG] resp status: 200
[DEBUG] resp body: [{'id': 1, 'name': ' grafana-backup', 'role': 'Admin', 'expiration': '2024-03-26T16:37:29Z'}]
...
I now see that the config file must live in the home directory in order to be detected automatically. In the context of my project, it would be more convenient to store this file in the project folder so that it can be version controlled (with sensitive information specified using env vars). Alternatively, this tool could check if the config file exists in the folder from where the tool is executed.
Is there any issue with putting the config file in whatever directory you want and then passing the --config
argument as you have already pointed out?
@acjohnson No, I can specify the config file with --config
. Closing this ticket as specifying the path to the config file should probably be the preferred way instead of using magic/hidden config file location.