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
|
2019-11-11 19:33:00 +01:00
|
|
|
mkdir influxdb_data
|
|
|
|
influxd backup -database opentsdb influxdb_data
|
2017-02-18 16:45:43 +01:00
|
|
|
|
|
|
|
# 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"
|