2015-12-26 14:14:31 +01:00
#!/bin/bash
2018-02-11 01:20:58 +01:00
#=================================================
# GENERIC START
#=================================================
2020-11-17 23:49:06 +01:00
# Import common cmd
source ../settings/scripts/experimental_helper.sh
source ../settings/scripts/_common.sh
2017-07-21 14:56:41 +02:00
# Source YunoHost helpers
source /usr/share/yunohost/helpers
2015-12-26 14:14:31 +01:00
# retrieve useful param
2021-06-26 12:22:45 +02:00
seafile_version=$(ynh_app_upstream_version)
2015-12-26 14:14:31 +01:00
2020-12-15 22:09:09 +01:00
if [[ ! "$(systemctl status seafile)" =~ "Active: inactive (dead)" ]] || [[ ! "$(systemctl status seahub)" =~ "Active: failed (Result: signal)" ]]; then
2020-11-29 17:29:51 +01:00
ynh_print_warn --message="It's hightly recommended to make your backup when the service is stopped. Please stop seafile service and seahub service with this command before to run the backup 'systemctl stop seafile.service seahub.service'"
2020-11-29 17:29:51 +01:00
fi
2018-02-11 01:20:58 +01:00
#=================================================
# STANDARD BACKUP STEPS
#=================================================
2017-07-21 14:56:41 +02:00
# # Backup app files
2020-12-12 15:03:12 +01:00
ynh_print_info --message="Backing up code..."
2023-08-08 23:21:11 +02:00
ynh_backup --src_path $install_dir
2020-12-12 15:03:12 +01:00
ynh_print_info --message="Backing up user data..."
2023-10-26 10:14:27 +02:00
ynh_backup --src_path=$data_dir --dest_path="data" --is_big=1
2020-12-12 15:03:12 +01:00
ynh_print_info --message="Backing up configuration..."
2019-06-11 22:28:26 +02:00
ynh_backup --src_path /etc/nginx/conf.d/$domain.d/${app}.conf
ynh_backup --src_path /etc/systemd/system/seafile.service
ynh_backup --src_path /etc/systemd/system/seahub.service
2019-06-12 22:56:50 +02:00
ynh_backup --src_path /etc/fail2ban/jail.d/$app.conf
ynh_backup --src_path /etc/fail2ban/filter.d/$app.conf
2015-12-26 14:14:31 +01:00
# Backup mysql
2020-12-12 15:03:12 +01:00
ynh_print_info --message="Backing up database"
2023-09-27 20:13:07 +02:00
ynh_mysql_dump_db --database $db_name > ${YNH_CWD}/seafiledb.dmp
2019-06-11 22:28:26 +02:00
ynh_mysql_dump_db --database ccnetdb > ${YNH_CWD}/ccnetdb.dmp
ynh_mysql_dump_db --database seahubdb > ${YNH_CWD}/seahubdb.dmp
2020-12-12 15:03:12 +01:00
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."