2017-04-10 04:55:10 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2018-05-01 20:43:49 +02:00
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
2017-04-10 04:55:10 +02:00
|
|
|
|
2018-04-06 19:58:23 +02:00
|
|
|
if [ ! -e _common.sh ]; then
|
2018-05-01 20:43:49 +02:00
|
|
|
# Get the _common.sh file if it's not in the current directory
|
|
|
|
cp ../settings/scripts/_common.sh ./_common.sh
|
|
|
|
cp ../settings/scripts/_future.sh ./_future.sh
|
|
|
|
chmod a+rx _common.sh _future.sh
|
2017-04-19 02:37:40 +02:00
|
|
|
fi
|
2018-04-06 19:58:23 +02:00
|
|
|
source _common.sh
|
2017-04-10 04:55:10 +02:00
|
|
|
source /usr/share/yunohost/helpers
|
2018-05-01 20:43:49 +02:00
|
|
|
source _future.sh
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# MANAGE SCRIPT FAILURE
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
# Exit if an error occurs during the execution of the script
|
|
|
|
ynh_abort_if_errors
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# LOAD SETTINGS
|
|
|
|
#=================================================
|
2017-04-10 04:55:10 +02:00
|
|
|
|
2017-04-19 02:37:40 +02:00
|
|
|
# Get multi-instances specific variables
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
|
2017-04-10 04:55:10 +02:00
|
|
|
# Retrieve app settings
|
|
|
|
domain=$(ynh_app_setting_get "$app" domain)
|
2018-05-01 20:43:49 +02:00
|
|
|
final_path=$(ynh_app_setting_get "$app" final_path)
|
2018-06-12 22:53:03 +02:00
|
|
|
db_name=$(ynh_app_setting_get "$app" db_name)
|
|
|
|
if [ -z "$db_name" ]; then
|
|
|
|
db_name="${app}_production"
|
|
|
|
ynh_app_setting_set "$app" db_name "$db_name"
|
|
|
|
fi
|
2017-04-10 04:55:10 +02:00
|
|
|
|
2018-05-01 20:43:49 +02:00
|
|
|
#=================================================
|
|
|
|
# STANDARD BACKUP STEPS
|
|
|
|
#=================================================
|
|
|
|
# BACKUP THE APP MAIN DIR
|
|
|
|
#=================================================
|
2017-04-10 04:55:10 +02:00
|
|
|
|
2018-05-01 20:43:49 +02:00
|
|
|
ynh_backup "$final_path"
|
2017-07-13 00:12:42 +02:00
|
|
|
|
2018-05-01 20:43:49 +02:00
|
|
|
#=================================================
|
|
|
|
# BACKUP THE NGINX CONFIGURATION
|
|
|
|
#=================================================
|
2017-04-10 04:55:10 +02:00
|
|
|
|
2018-05-01 20:43:49 +02:00
|
|
|
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
|
2017-07-13 00:12:42 +02:00
|
|
|
|
2018-05-01 20:43:49 +02:00
|
|
|
#=================================================
|
|
|
|
# BACKUP THE MYSQL DATABASE
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_psql_dump_db "$db_name" > db.sql
|
2018-05-01 11:29:25 +02:00
|
|
|
|
2018-05-01 20:43:49 +02:00
|
|
|
#=================================================
|
|
|
|
# SPECIFIC BACKUP
|
|
|
|
#=================================================
|
|
|
|
# BACKUP SYSTEMD
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_backup "/etc/systemd/system/$app-web.service"
|
|
|
|
ynh_backup "/etc/systemd/system/$app-sidekiq.service"
|
|
|
|
ynh_backup "/etc/systemd/system/$app-streaming.service"
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# BACKUP THE sources.list FILES
|
|
|
|
#=================================================
|
2018-06-12 18:32:43 +02:00
|
|
|
if [ "$(lsb_release --codename --short)" == "jessie" ]; then
|
|
|
|
ynh_backup "/etc/apt/sources.list.d/backports.list" "apt_backports.list"
|
|
|
|
fi
|
2018-05-01 20:43:49 +02:00
|
|
|
ynh_backup "/etc/apt/sources.list.d/yarn.list" "apt_yarn.list"
|