ysde/grafana-backup-tool

Backup fails for datasources with multiple slashes in their name

bryan-kc opened this issue · 2 comments

Reappearance of the bug found in #114

The backup utility fails for this data source. The data source has a name that includes the full path to the data source

FileNotFoundError: [Errno 2] No such file or directory: '_OUTPUT_/datasources/202111191136/Graphite | MetricTank | https://example.com/graphite.datasource'

@bryan-kc Can you provide the entire stack trace rather than just the error. It should provide output and file line information to help us know where the error is occuring

Hi, sorry for not including the stacktrace. See the included trace below.

Traceback (most recent call last):
  File "/usr/local/bin/grafana-backup", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.9/site-packages/grafana_backup/cli.py", line 50, in main
    save(args, settings)
  File "/usr/local/lib/python3.9/site-packages/grafana_backup/save.py", line 51, in main
    backup_functions[backup_function](args, settings)
  File "/usr/local/lib/python3.9/site-packages/grafana_backup/save_datasources.py", line 22, in main
    get_all_datasources_and_save(folder_path, grafana_url, http_get_headers, verify_ssl, client_cert, debug, pretty_print)
  File "/usr/local/lib/python3.9/site-packages/grafana_backup/save_datasources.py", line 38, in get_all_datasources_and_save
    save_datasource(datasource['name'], datasource, folder_path, pretty_print)
  File "/usr/local/lib/python3.9/site-packages/grafana_backup/save_datasources.py", line 27, in save_datasource
    file_path = save_json(file_name, datasource_setting, folder_path, 'datasource', pretty_print)
  File "/usr/local/lib/python3.9/site-packages/grafana_backup/commons.py", line 47, in save_json
    with open(u"{0}".format(file_path), 'w') as f:
FileNotFoundError: [Errno 2] No such file or directory: '_OUTPUT_/datasources/202111191136/Graphite | MetricTank | https://example.com/graphite.datasource'