forked from ysde/grafana-backup-tool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackup_grafana.sh
executable file
·33 lines (25 loc) · 1 KB
/
backup_grafana.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/bash
current_path=`pwd`
current_time=`date +"%Y-%m-%d_%T"`
compressed_dashboards_name="dashboards.tar.gz"
compressed_datasources_name="datasources.tar.gz"
compressed_folders_name="folders.tar.gz"
echo $current_time
dashboard_backup_path="/tmp/dashboards/$current_time"
datasource_backup_path="/tmp/datasources/$current_time"
folders_backup_path="/tmp/folders/$current_time"
if [ ! -d "$dashboard_backup_path" ]; then
mkdir -p "$dashboard_backup_path"
fi
if [ ! -d "$datasource_backup_path" ]; then
mkdir -p "$datasource_backup_path"
fi
if [ ! -d "$folders_backup_path" ]; then
mkdir -p "$folders_backup_path"
fi
python "${current_path}/saveDashboards.py" $dashboard_backup_path
python "${current_path}/saveDatasources.py" $datasource_backup_path
python "${current_path}/saveFolders.py" $folders_backup_path
tar -zcvf "/tmp/$compressed_dashboards_name" $dashboard_backup_path
tar -zcvf "/tmp/$compressed_datasources_name" $datasource_backup_path
tar -zcvf "/tmp/$compressed_folders_name" $folders_backup_path