1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/funkwhale_ynh.git synced 2024-09-03 18:36:24 +02:00
funkwhale_ynh/scripts/backup
yalh76 33392f79e9
Apply Example_ynh (#131)
* Testing (#130)

* Uprade to 1.1 and fixes Twisted by retrograding it (#129)

* Apply example_ynh

Fix #15

* Fix services

* Fix several merging

* Stick to official install process

* fix path_transversal

* Using option '--log_type systemd' with 'yunohost service add' is not relevant anymore

* Try to fix package_check

* Fix package_check test

* Update check_process

* Trying to fix package_check

* Update env.prod

* remove sleep

* Better service name

* missing datadir

* line 111: upgrade_type: unbound variable

* Implement --is_big

* Fix stopping service from previous version

* Fix upgrade

* Fix upgrade

* Apply example_ynh

* Apply example_ynh

* Fix rights

* Update api.src

* Update env.prod

* Update front.src

* Update manifest.json

* Update README.md

* Update README_fr.md

* Fix chmod

* Fix rights

Co-authored-by: Thomas <51749973+Thovi98@users.noreply.github.com>
Co-authored-by: Éric Gaspar <46165813+ericgaspar@users.noreply.github.com>
2021-04-16 14:14:27 +02:00

87 lines
2.9 KiB
Bash

#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# 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
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
ynh_clean_check_starting
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# 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)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
#=================================================
# DECLARE DATA AND CONF FILES TO BACKUP
#=================================================
ynh_print_info --message="Declaring files to be backed up..."
#=================================================
# BACKUP THE APP MAIN DIR
#=================================================
ynh_backup --src_path="$final_path"
#=================================================
# BACKUP THE NGINX CONFIGURATION
#=================================================
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# BACKUP FAIL2BAN CONFIGURATION
#=================================================
ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf"
ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf"
#=================================================
# SPECIFIC BACKUP
#=================================================
# BACKUP SYSTEMD
#=================================================
ynh_backup --src_path="/etc/systemd/system/${app}-beat.service"
ynh_backup --src_path="/etc/systemd/system/${app}-server.service"
ynh_backup --src_path="/etc/systemd/system/${app}-worker.service"
ynh_backup --src_path="/etc/systemd/system/$app.target"
#=================================================
# BACKUP VARIOUS FILES
#=================================================
ynh_backup --src_path="$datadir" --is_big
#=================================================
# BACKUP THE POSTGRESQL DATABASE
#=================================================
ynh_print_info --message="Backing up the PostgreSQL database..."
ynh_psql_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)."