1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/grafana_ynh.git synced 2024-09-03 20:36:29 +02:00
grafana_ynh/scripts/backup

50 lines
1.4 KiB
Text
Raw Normal View History

2017-02-18 16:45:43 +01:00
#!/bin/bash
2017-12-03 19:24:03 +01:00
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
2017-02-18 16:45:43 +01:00
2017-12-03 19:24:03 +01:00
if [ ! -e _common.sh ]; then
# Fetch helpers file if not in current directory
cp ../settings/scripts/_common.sh ./_common.sh
chmod a+rx _common.sh
fi
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
2017-02-18 16:45:43 +01:00
app=$YNH_APP_INSTANCE_NAME
# Source YunoHost helpers
source /usr/share/yunohost/helpers
# Backup configuration files
ynh_backup "/etc/influxdb" "conf_influxdb"
ynh_backup "/etc/grafana" "conf_grafana"
ynh_backup "/var/lib/grafana/plugins" "conf_grafana_plugins"
# Backup InfluxDB data
# Source: http://stackoverflow.com/questions/39501416/how-to-restore-data-base-using-influxd
TMPDIR=$(mktemp -d)
influxd backup -database opentsdb $TMPDIR
2017-02-18 16:45:43 +01:00
ynh_backup "$TMPDIR" "influxdb_data"
# Dump the Grafana database
dbname=$app
dbuser=$app
dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
mysqldump -u "$dbuser" -p"$dbpass" --no-create-db "$dbname" > ./dump.sql
# Copy NGINX configuration
domain=$(ynh_app_setting_get "$app" domain)
ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf" "nginx.conf"