1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/abantecart_ynh.git synced 2024-09-03 18:06:16 +02:00

Big Refactoring

This commit is contained in:
frju365 2018-02-11 19:22:11 +01:00 committed by GitHub
parent 7e806dec0e
commit b7b640623d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,32 +1,68 @@
#!/bin/bash
set -eu
# Source app helpers
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
if [ ! -e _common.sh ]; then
# Get the _common.sh file if it's not in the current directory
cp ../settings/scripts/_common.sh ./_common.sh
chmod a+rx _common.sh
fi
source _common.sh
source /usr/share/yunohost/helpers
# Récupère les infos de l'application.
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get $app final_path)
domain=$(ynh_app_setting_get $app domain)
db_name=$(ynh_app_setting_get $app db_name)
# The parameter $1 is the backup directory location
# which will be compressed afterward
#=================================================
# STANDARD BACKUP STEPS
#=================================================
# BACKUP THE APP MAIN DIR
#=================================================
# Backup sources & data
ynh_backup "$final_path" "sources"
ynh_backup "$final_path"
# Copy Nginx and YunoHost parameters to make the script "standalone"
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" "nginx.conf"
#=================================================
# BACKUP THE NGINX CONFIGURATION
#=================================================
ynh_backup "/etc/yunohost/apps/$app/" "yunohost"
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
# Copy dedicated php-fpm process to backup folder
ynh_backup "/etc/php5/fpm/pool.d/$app.conf" "php-fpm.conf"
#=================================================
# BACKUP THE PHP-FPM CONFIGURATION
#=================================================
# Backup db
root_pwd=$(sudo cat /etc/yunohost/mysql)
sudo mysqldump -u root -p$root_pwd --no-create-db $db_user --result-file="db.sql"
ynh_backup "db.sql" "backupdb.sql"
ynh_backup "/etc/php5/fpm/pool.d/$app.conf"
ynh_backup "/etc/php5/fpm/conf.d/20-$app.ini"
#=================================================
# BACKUP THE MYSQL DATABASE
#=================================================
ynh_mysql_dump_db "$db_name" > db.sql
#=================================================
# SPECIFIC BACKUP
#=================================================
# BACKUP LOGROTATE
#=================================================
ynh_backup "/etc/logrotate.d/$app"