2015-11-18 17:22:55 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2017-09-11 08:29:58 +02:00
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
2017-10-10 13:00:33 +02:00
|
|
|
#=================================================
|
|
|
|
# MANAGE SCRIPT FAILURE
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
# Exit if an error occurs during the execution of the script
|
|
|
|
ynh_abort_if_errors
|
|
|
|
|
2017-09-11 08:29:58 +02:00
|
|
|
#=================================================
|
|
|
|
# LOAD SETTINGS
|
|
|
|
#=================================================
|
2017-09-11 12:05:16 +02:00
|
|
|
|
2017-09-11 08:29:58 +02:00
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
|
|
|
|
final_path="/var/www/$app"
|
2018-01-29 06:45:24 +01:00
|
|
|
data_path="/home/yunohost.app/$app"
|
2017-09-11 08:29:58 +02:00
|
|
|
domain=$(ynh_app_setting_get $app domain)
|
2017-02-04 19:20:51 +01:00
|
|
|
db_name="$app"
|
2017-09-11 08:29:58 +02:00
|
|
|
default_backup_dir="${1}apps/$app"
|
|
|
|
backup_dir=${backup_dir:-"$default_backup_dir"}
|
2015-11-18 17:22:55 +01:00
|
|
|
|
2017-09-11 08:29:58 +02:00
|
|
|
#=================================================
|
|
|
|
# STANDARD BACKUP STEPS
|
|
|
|
#=================================================
|
|
|
|
# BACKUP THE APP MAIN DIR
|
|
|
|
#=================================================
|
2015-11-18 17:22:55 +01:00
|
|
|
|
2017-09-11 08:29:58 +02:00
|
|
|
ynh_backup "$final_path" "${backup_dir}$final_path"
|
2015-11-18 17:22:55 +01:00
|
|
|
|
2018-01-29 06:45:24 +01:00
|
|
|
#=================================================
|
|
|
|
# BACKUP THE APP DATA
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_backup "$data_path" "${backup_dir}$data_path"
|
|
|
|
|
2017-09-11 08:29:58 +02:00
|
|
|
#=================================================
|
|
|
|
# BACKUP THE DATABASE
|
|
|
|
#=================================================
|
2015-11-18 17:22:55 +01:00
|
|
|
|
2017-09-11 08:29:58 +02:00
|
|
|
ynh_mysql_dump_db "$db_name" > db.sql
|
|
|
|
ynh_backup "db.sql" "${backup_dir}/db.sql"
|
2015-11-18 17:22:55 +01:00
|
|
|
|
2017-09-11 08:29:58 +02:00
|
|
|
#=================================================
|
|
|
|
# BACKUP THE NGINX CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" "${backup_dir}/etc/nginx/conf.d/$domain.d/$app.conf"
|
|
|
|
|
|
|
|
#=================================================
|
2017-10-12 12:47:51 +02:00
|
|
|
# BACKUP SYSTEMD
|
2017-09-11 08:29:58 +02:00
|
|
|
#=================================================
|
|
|
|
|
2017-10-12 12:47:51 +02:00
|
|
|
ynh_backup "/etc/systemd/system/$app.service" "${backup_dir}/etc/systemd/system/$app.service"
|