2018-02-25 21:45:24 +01:00
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
2020-11-17 23:33:50 +01:00
# Load common variables and helpers
source ../settings/scripts/_common.sh
2018-02-25 21:45:24 +01:00
source /usr/share/yunohost/helpers
2024-04-08 00:26:39 +02:00
if systemctl is-active $app.service --quiet; then
2024-02-07 12:06:16 +01:00
ynh_print_warn --message="It's hightly recommended to make your backup when the service is stopped. Please stop $app service with this command before to run the backup 'systemctl stop $app.service'"
2020-12-07 15:11:16 +01:00
fi
2018-02-25 21:45:24 +01:00
#=================================================
2023-09-09 11:17:52 +02:00
# DECLARE DATA AND CONF FILES TO BACKUP
2018-02-25 21:45:24 +01:00
#=================================================
2023-11-29 10:58:11 +01:00
ynh_print_info --message='Declaring files to be backed up...'
2018-02-25 21:45:24 +01:00
# Copy the app source files
2024-04-26 22:00:58 +02:00
ynh_backup --src_path="$install_dir"
2018-02-25 21:45:24 +01:00
# Copy the data files
2024-04-26 22:00:58 +02:00
ynh_backup --src_path="$data_dir" --is_big=1
2019-09-10 22:43:45 +02:00
2018-02-25 21:45:24 +01:00
# Copy the conf files
2024-04-26 22:00:58 +02:00
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
2023-09-09 11:17:52 +02:00
ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf"
ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf"
ynh_backup --src_path="/etc/logrotate.d/$app"
2024-04-26 22:00:58 +02:00
ynh_backup --src_path="/etc/systemd/system/$app.service"
2018-02-25 21:45:24 +01:00
# Backup logs
2024-04-26 22:00:58 +02:00
ynh_backup --src_path="/var/log/$app"
2018-02-25 21:45:24 +01:00
# Dump the database
2023-09-09 11:17:52 +02:00
ynh_print_info --message="Backing up the MySQL database"
ynh_mysql_dump_db "$db_name" > ./db.sql
#=================================================
# END OF SCRIPT
#=================================================
2019-10-27 14:54:35 +01:00
2020-12-08 22:06:19 +01:00
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."