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

Restore does not restore all files or give any indication of failure #5

Open
omadawn opened this issue Nov 22, 2017 · 3 comments
Open
Labels

Comments

@omadawn
Copy link
Contributor

omadawn commented Nov 22, 2017

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

@omadawn
Copy link
Contributor Author

omadawn commented Nov 22, 2017

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.

@omadawn
Copy link
Contributor Author

omadawn commented Nov 22, 2017

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.

@grafov
Copy link
Member

grafov commented Nov 23, 2017

I agree it is wrong behavior. PR proposed by you is ok solution.

@grafov grafov added the bug label Nov 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants