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
2024-04-12 22:19:27 +02:00
seafile_version=$(ynh_app_upstream_version)
2024-05-30 23:22:07 +02:00
seafile_code="$install_dir/seafile_image/opt/seafile/seafile-server-$seafile_version"
2024-04-12 22:19:27 +02:00
2024-04-08 00:30:00 +02:00
if systemctl is-active seafile --quiet || systemctl is-active seahub --quiet; then
2024-08-31 02:59:12 +02:00
ynh_print_warn "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
2024-08-31 02:59:12 +02:00
ynh_print_info "Backing up code..."
ynh_backup "$install_dir"
ynh_print_info "Backing up user data..."
ynh_backup "$data_dir" --dest_path="data"
ynh_print_info "Backing up configuration..."
ynh_backup "/etc/nginx/conf.d/$domain.d/${app}.conf"
ynh_backup /etc/systemd/system/seafile.service
ynh_backup /etc/systemd/system/seahub.service
ynh_backup /etc/fail2ban/jail.d/"$app".conf
ynh_backup /etc/fail2ban/filter.d/"$app".conf
2015-12-26 14:14:31 +01:00
2024-04-21 12:26:32 +02:00
# Backup logs
2024-08-31 02:59:12 +02:00
ynh_backup "/var/log/$app"
2024-04-21 12:26:32 +02:00
2015-12-26 14:14:31 +01:00
# Backup mysql
2024-08-31 02:59:12 +02:00
ynh_print_info "Backing up database"
ynh_mysql_dump_db > "${YNH_CWD}"/seafiledb.dmp
2024-04-26 21:55:00 +02:00
ynh_mysql_dump_db --database=ccnetdb > "${YNH_CWD}"/ccnetdb.dmp
ynh_mysql_dump_db --database=seahubdb > "${YNH_CWD}"/seahubdb.dmp
2019-06-11 22:28:26 +02:00
2024-08-31 02:59:12 +02:00
ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."