Open omadawn opened 6 years ago
Additional troubleshooting shows that:
A) Only one file is restored even if the file string matches multiple files I.E. $ ./grafana-backup -verbose restore testEnvironmentBackup/*.json Dashboard restored from testEnvironmentBackup/app-team-roll-up-start.db.json.
B) It does not restore datasources. $ ./grafana-backup -verbose restore testEnvironmentBackup/prometheus-test.ds.1.json Dashboard restored from testEnvironmentBackup/prometheus-test.ds.1.json.
Navigate to the grafana server and there is no new datasource.
O.K. I see what's causing A. It's shell expansion. It imports multiple files if you quote the restore pattern. $ ./grafana-backup -verbose restore 'testEnvironmentBackup/*'
For: $ ./grafana-backup -verbose restore testEnvironmentBackup/*
'testEnvironmentBackup/*' is first being expanded by the shell. So what's really being passed to grafana-backup is
'-verbose restore testEnvironmentBackup/app-team-roll-up-start.db.json testEnvironmentBackup/big-ip-device-statistics-from-snmp.db.json testEnvironmentBackup/big-ip-overview.db.json testEnvironmentBackup/node-exporter-full-v3.db.json testEnvironmentBackup/node-exporter-full.db.json testEnvironmentBackup/prometheus-2-0-overview.db.json testEnvironmentBackup/prometheus-data-exploration.db.json testEnvironmentBackup/prometheus-stats-customized.db.json testEnvironmentBackup/prometheus-stats.db.json testEnvironmentBackup/prometheus-test.ds.1.json'
And since we are only grabbing args[1] we only get the first file
if flag.NArg() > 1 {
argPath = args[1]
}
So this could either be an update to the usage/readme or we could update it to accept a list of files.
If you're O.K. with requiring that the pattern be quoted I would prefer it be turned into a command line flag instead of just a bare argument to make it more obvious that the user is passing a search string instead of a list of files.
I agree it is wrong behavior. PR proposed by you is ok solution.
Did a backup of a grafana instance which produced nine dashboard files and a single datasource file.
Ran the restore on the same set of files but to a different grafana server. It restored one of the dashboards and did not restore the datasource. Even with -verbose it simply read Dashboard restored from app-team-roll-up-start.db.json