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

71 lines
2.5 KiB
Text
Raw Permalink Normal View History

2017-02-18 16:45:43 +01:00
#!/bin/bash
2020-05-17 09:28:22 +02:00
#=================================================
# GENERIC START
2017-12-03 19:24:03 +01:00
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
2017-02-18 16:45:43 +01:00
2021-08-22 16:17:29 +02:00
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
2020-05-17 09:28:22 +02:00
source ../settings/scripts/_common.sh
2017-12-03 19:24:03 +01:00
source /usr/share/yunohost/helpers
2020-05-17 09:28:22 +02:00
#=================================================
2021-08-22 16:17:29 +02:00
# DECLARE DATA AND CONF FILES TO BACKUP
2020-05-24 15:53:05 +02:00
#=================================================
ynh_print_info --message="Declaring files to be backed up..."
2020-05-17 09:28:22 +02:00
#=================================================
# BACKUP THE NGINX CONFIGURATION
#=================================================
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# SPECIFIC BACKUP
#=================================================
2020-05-24 15:53:05 +02:00
ynh_print_info --message="Backing up the InfluxDB database..."
2021-08-03 08:02:26 +02:00
2017-02-18 16:45:43 +01:00
# 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
# Backup only if database exists (compatible with automated tests where NetData is not present)
# and if BACKUP_CORE_ONY/do_not_backup_data not set
BACKUP_CORE_ONLY=${BACKUP_CORE_ONLY:-0}
do_not_backup_data=$(ynh_app_setting_get --app=$app --key=do_not_backup_data)
2020-05-17 09:28:22 +02:00
if [ -d "/var/lib/influxdb/data/opentsdb" ]; then
if ( [ ${do_not_backup_data:-0} -eq 1 ] || [ $BACKUP_CORE_ONLY -eq 1 ] )
then
if [ $BACKUP_CORE_ONLY -eq 1 ]
then
ynh_print_warn --message="The InfluxDB database will not be saved, because 'BACKUP_CORE_ONLY' is set."
else
ynh_print_warn --message="The InfluxDB database will not be saved, because 'do_not_backup_data' is set."
fi
else
influxd backup -portable influxdb_data
fi
2020-05-17 09:28:22 +02:00
fi
2021-08-22 16:17:29 +02:00
#=================================================
# BACKUP VARIOUS FILES
#=================================================
ynh_backup --src_path="/etc/influxdb"
ynh_backup --src_path="/etc/$app"
2022-03-06 19:14:26 +01:00
ynh_backup --src_path="/var/lib/grafana/plugins" --not_mandatory
2021-08-22 16:17:29 +02:00
#=================================================
# BACKUP THE MYSQL DATABASE
#=================================================
ynh_print_info --message="Backing up the MySQL database..."
ynh_mysql_dump_db --database="$db_name" > db.sql
2020-05-17 09:28:22 +02:00
#=================================================
# END OF SCRIPT
#=================================================
2017-02-18 16:45:43 +01:00
2020-05-24 15:53:05 +02:00
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."