#!/bin/bash #================================================= # IMPORT GENERIC HELPERS #================================================= # Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers #================================================= # DECLARE DATA AND CONF FILES TO BACKUP #================================================= ynh_print_info --message="Declaring files to be backed up..." #================================================= # APPLY BACKUP CORE ONLY POLICY #================================================= # Apply policy only if we are not in upgrade mode BACKUP_CORE_ONLY=${BACKUP_CORE_ONLY:-auto} if [ "$BACKUP_CORE_ONLY" == "auto" ] ; then BACKUP_CORE_ONLY=$(ynh_app_setting_get --app="$app" --key="backup_core_only") BACKUP_CORE_ONLY=${BACKUP_CORE_ONLY:-0} fi #================================================= # BACKUP THE APP MAIN DIR #================================================= # Clean cache files before backup (saved some disk space) ynh_secure_remove --file=$install_dir/var/cache/prod if [ "$BACKUP_CORE_ONLY" ] ; then ynh_print_warn --message="Backing up only the core... If you downloaded article images, they will not be saved." mv "$install_dir/web/assets/images" "/tmp/$app/web/assets/images" ynh_backup --src_path="$install_dir" mv "/tmp/$app/web/assets/images" "$install_dir/web/assets/images" else ynh_backup --src_path="$install_dir" fi #================================================= # BACKUP THE SYSTEM CONFIGURATION #================================================= ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" ynh_backup --src_path="/etc/logrotate.d/$app" ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf" ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf" #================================================= # BACKUP THE MYSQL DATABASE #================================================= ynh_print_info --message="Backing up the MySQL database..." ynh_mysql_dump_db --database="$db_name" > db.sql #================================================= # END OF SCRIPT #================================================= ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."