Giter Club home page Giter Club logo

grafana-backup-tool's Introduction

Grafana Dashboard Backup Tool

  • Save every datasource to each datasource file.
    • saveDatasources.py
  • Save every folder to each datasource file.
    • saveFolders.py
  • Save every dashboard to each dashboard file.
    • saveDashboards.py
  • Create datasource from a backup file.
    • createDatasource.py
  • Create dashboard from a backup file.
    • createDashboard.py
  • Create folder from a backup file. (supported from Grafana v.5.0.*)
    • createFolder.py

There a three convenient script files:

  1. backup_grafana.sh
  2. restore_dashboards.sh
  3. restore_datasources.sh
  4. restore_folders.sh

you can use them to

  1. backup all datasources, dashboards and folders.
    • e.g.: sh backup_grafana.sh
  2. restore dashboards from your dashboard backup folder.
    • e.g: sh restore_dashboards.sh /tmp/dashboards/2016-10-10_12:00:00
  3. restore datasources from your datasource backup folder.
    • e.g.: sh restore_dashboards.sh /tmp/datasources/2016-10-10_12:00:00
  4. restore folders from your folder backup folder.
    • e.g.: sh restore_folders.sh /tmp/folders/2016-10-10_12:00:00

Grafana API document

ENV:

  • python 2.7, python 3
    • Need to pip install requests library
  • Garafana 3.0 API

Setting

  1. Export the environment variables bellow
  2. GRAFANA_URL (the default url is http://localhost:3000)
  3. GRAFANA_TOKEN

You can see how to get token from here: Grafana Web page

How to Use

  • First edit grafanaSettings.py as above.

  • Use saveDashboards.py to save each dashboard to each file.

    • ex: python saveDashboards.py folder_path
  • Use saveDatasources.py to save each datasources to each file under specific folder.

    • ex: python saveDatasources.py folder_path
  • Use saveFolders.py to save each folders to each file under specific folder.

    • ex: python saveFolders.py folder_path
  • Use createDashboard.py to read the dashboard file and create or update them on Grafana.

    • ex: python createDashboard.py file_path
  • Use createDatasource.py to read the datasource file and create or update them on Grafana.

    • ex: python createDatasource.py file_path
  • Use createFolder.py to read the folder file and create or update them on Grafana.

    • ex: python createFolder.py file_path
  • Use backup_grafana.sh to backup all your dashboards, datasources and folders to /tmp folder.

    • It will create
      • three files:
        1. /tmp/dashboards.tar.gz
        2. /tmp/datasources.tar.gz
        3. /tmp/folders.tar.gz
      • three folders contain dashboard files, datasource files and folders file:
        1. /tmp/dashboards/$current_time
        2. /tmp/datasources/$current_time
        3. /tmp/folders/$current_time
    • e.g.:sh backup_grafana.sh
    • result:
      • /tmp/dashboads.tar.gz
      • /tmp/datasourcess.tar.gz
      • /tmp/folders.tar.gz

      • /tmp/dashboards/2016-10-10_12:00:00
      • /tmp/datasources/2016-10-10_12:00:00
      • /tmp/folders/2016-10-10_12:00:00

grafana-backup-tool's People

Contributors

gustavosoares avatar rdoering avatar the-smooth-operator avatar ysde avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.