项目作者: grafana-tools

项目描述 :
[ON HOLD] CLI tool for backup/restore Grafana dashboards and datasources.
高级语言: Go
项目地址: git://github.com/grafana-tools/grafana-backup.git
创建时间: 2016-11-17T22:57:45Z
项目社区:https://github.com/grafana-tools/grafana-backup

开源协议:GNU General Public License v3.0

下载


Backup tool for Gafana

CLI for the simple backup/restore operations of Grafana dashboards and datasources.
It uses Grafana client SDK.

Work in progress. Current state: it may works, may not. Depends on build. Don’t use it yet!

Examples

Back up all dashboards and any datasources which they require. Backups will be saved as separate files in
the directory $CWD/backup

$ grafana-backup -url http://127.1:3000 -key xxxxxxxx backup

Show all dashboards which have the flags “tagone” and “tagtwo” applied and any datasources they use.

  1. $ grafana-backup -tag tagone,tagtwo ls
  2. <31> "Test Dashboard 1" [tagone tagtwo]
  3. <10> "prometheus-test" (prometheus) http://prometheus-test.example.com:9090
  4. <8> "Promt2Local" (prometheus) http://prometheus-poc.example.com:9090

Show the dashboard titled “Test Dashboard 3” and the datasources it uses.

  1. $ grafana-backup -title 'Test Dashboard 3' ls
  2. <33> "Test Dashboard 3" []
  3. <10> "prometheus-test" (prometheus) http://prometheus-test.example.com:9090
  4. <8> "Promt2Local" (prometheus) http://prometheus-poc.example.com:9090

Back up all dashboards which have the flags “tag1” and “tag2” applied and any datasources they use.

  1. $ grafana-backup -url http://127.1:3000 -key xxxxxxxx -tag tag1,tag2 backup

Back up a dashboard called “sample”

  1. $ grafana-backup -url http://127.1:3000 -key xxxxxxxx -tag tag1,tag2 -title sample backup

Back up all dashboards, datasources and users

  1. $ grafana-backup -url http://127.1:3000 -key xxxxxxxx -apply-for all

Show information about local backup files

  1. $ grafana-backup ls-files
  2. test-dashboard-1.db.json: board id:31 "Test Dashboard 1" [tagone tagtwo]
  3. test-dashboard-2.db.json: board id:32 "Test Dashboard 2"
  4. test-dashboard-3.db.json: board id:33 "Test Dashboard 3"

Restore all local objects which have the tag “tag1” applied to them.

  1. $ grafana-backup -url http://127.1:3000 -key xxxxxxxx -tag tag1 restore

View the usage

  1. $ grafana-backup
  2. Backup tool for Grafana.
  3. Copyright (C) 2016-2017 Alexander I.Grafov <siberian@laika.name>
  4. This program comes with ABSOLUTELY NO WARRANTY.
  5. This is free software, and you are welcome to redistribute it
  6. under conditions of GNU GPL license v3.
  7. Usage: $ grafana-backup [flags] <command>
  8. Available commands are: backup, restore, ls, ls-files, info, config, help.
  9. Call 'grafana-backup help <command>' for details about the command.
  10. -apply-for string
  11. apply operation only for some kind of objects, available values are "auto", "all", "dashboards", "datasources", "users" (default "auto")
  12. -dir string
  13. A directory to write backup files to or read them from. (default "backup")
  14. -force
  15. force overwrite of existing objects
  16. -key string
  17. API key of Grafana server
  18. -starred
  19. only match starred dashboards
  20. -tag string
  21. dashboard should match all these tags
  22. -timeout duration
  23. read flagTimeout for interacting with Grafana in seconds (default 6m0s)
  24. -title string
  25. dashboard title should match name
  26. -url string
  27. URL of Grafana server
  28. -verbose
  29. verbose output

List of proposed commands, flags and args

Draft and it is subject for changes.

  1. # List dashboards.
  2. $ grafana-backup -key=xxxx -url=x.y.z -title=match-name -tag=x,y,z ls
  3. # List datasources.
  4. $ grafana-backup -key=xxxx -url=x.y.z ls-ds
  5. # List users.
  6. $ grafana-backup -key=xxxx -url=x.y.z ls-users
  7. # Do backup for matching dashboards.
  8. $ grafana-backup -key=xxxx -url=x.y.z -title=match-name -tag=x,y,z backup path/to
  9. # Restore objects on a server at url only for boards match tags.
  10. $ grafana-backup -key=xxxx -url=x.y.z -tag x,y,z restore path/from
  11. # List local backups for tags and file mask
  12. $ grafana-backup -tag x,y,z -file "backup/*/*" ls-files
  13. # Save all flags to config var.
  14. $ grafana-backup -key=xxxx -url=x.y.z config-set confname
  15. # Get flag values for config variable.
  16. $ grafana-backup config-get confname
  17. # Flag applied for backup/restore
  18. -objects=auto,dashboards,datasources,users,all