1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/gogs_ynh.git synced 2024-09-03 20:36:23 +02:00
gogs_ynh/scripts/backup

83 lines
2.5 KiB
Text
Raw Normal View History

2016-08-15 15:38:50 +02:00
#!/bin/bash
2018-02-08 17:25:54 +01:00
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
2020-10-11 23:46:18 +02:00
#=================================================
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
2016-08-15 15:38:50 +02:00
2020-10-11 23:46:18 +02:00
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_abort_if_errors
2016-08-15 15:38:50 +02:00
2020-10-11 23:46:18 +02:00
#=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
domain=$(ynh_app_setting_get --app=$app --key=domain)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
2021-11-07 09:17:22 +01:00
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
2016-08-15 15:38:50 +02:00
2020-10-11 23:46:18 +02:00
#=================================================
# DECLARE DATA AND CONF FILES TO BACKUP
#=================================================
ynh_print_info --message="Declaring files to be backed up..."
2016-08-15 15:38:50 +02:00
2018-02-08 17:25:54 +01:00
#=================================================
2020-10-11 23:46:18 +02:00
# BACKUP THE APP MAIN DIR
2018-02-08 17:25:54 +01:00
#=================================================
2020-12-06 14:40:38 +01:00
ynh_backup --src_path="$final_path"
2016-08-15 15:38:50 +02:00
2021-11-07 09:17:22 +01:00
#=================================================
# BACKUP THE DATA DIR
#=================================================
ynh_backup --src_path="$datadir" --is_big
2016-08-15 15:38:50 +02:00
2020-10-11 23:46:18 +02:00
#=================================================
# BACKUP THE NGINX CONFIGURATION
#=================================================
2020-12-06 14:40:38 +01:00
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
2020-10-11 23:46:18 +02:00
#=================================================
2021-11-06 19:10:24 +01:00
# BACKUP LOGROTATE
2020-10-11 23:46:18 +02:00
#=================================================
2021-11-06 19:10:24 +01:00
ynh_backup --src_path="/etc/logrotate.d/$app"
2016-08-15 15:38:50 +02:00
2020-10-11 23:46:18 +02:00
#=================================================
2021-11-06 19:10:24 +01:00
# BACKUP SYSTEMD
2020-10-11 23:46:18 +02:00
#=================================================
2021-11-06 19:10:24 +01:00
ynh_backup --src_path="/etc/systemd/system/$app.service"
2018-02-08 11:42:15 +01:00
2020-12-30 15:07:15 +01:00
#=================================================
2021-11-06 19:10:24 +01:00
# BACKUP VARIOUS FILES
2020-12-30 15:07:15 +01:00
#=================================================
2021-11-06 19:10:24 +01:00
ynh_backup --src_path="/var/log/$app"
2020-12-30 15:07:15 +01:00
2020-10-11 23:46:18 +02:00
#=================================================
# 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)."