2020-02-23 12:02:10 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
2022-03-13 17:45:45 +01:00
|
|
|
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
2020-02-23 12:02:10 +01:00
|
|
|
source ../settings/scripts/_common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# MANAGE SCRIPT FAILURE
|
|
|
|
#=================================================
|
|
|
|
|
2022-03-13 17:45:45 +01:00
|
|
|
ynh_clean_setup () {
|
|
|
|
ynh_clean_check_starting
|
|
|
|
}
|
2020-02-23 12:02:10 +01:00
|
|
|
# Exit if an error occurs during the execution of the script
|
|
|
|
ynh_abort_if_errors
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# LOAD SETTINGS
|
|
|
|
#=================================================
|
2022-03-13 17:45:45 +01:00
|
|
|
ynh_script_progression --message="Loading installation settings..."
|
2020-02-23 12:02:10 +01:00
|
|
|
|
2021-03-07 14:03:37 +01:00
|
|
|
export app=$YNH_APP_INSTANCE_NAME
|
2020-02-23 12:02:10 +01:00
|
|
|
|
2022-03-13 17:45:45 +01:00
|
|
|
export server=$(ynh_app_setting_get --app=$app --key=server)
|
2021-03-07 14:03:37 +01:00
|
|
|
|
|
|
|
export final_path="/opt/yunohost/${app}"
|
2020-02-23 12:02:10 +01:00
|
|
|
|
|
|
|
#=================================================
|
2020-04-12 17:13:11 +02:00
|
|
|
# INSTALL RESTIC
|
2020-02-23 12:02:10 +01:00
|
|
|
#=================================================
|
|
|
|
install_restic
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# ACTIVATE BACKUP METHODS
|
|
|
|
#=================================================
|
|
|
|
mkdir -p /etc/yunohost/hooks.d/backup_method
|
|
|
|
mkdir -p /usr/share/yunohost/backup_method
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# RESTORE FILES
|
|
|
|
#=================================================
|
2022-03-13 17:45:45 +01:00
|
|
|
|
2020-11-12 08:23:18 +01:00
|
|
|
ynh_restore
|
2020-02-23 12:02:10 +01:00
|
|
|
|
|
|
|
#=================================================
|
2021-02-27 22:49:02 +01:00
|
|
|
# ENABLE TIMER
|
2020-02-23 12:02:10 +01:00
|
|
|
#=================================================
|
2022-03-13 17:45:45 +01:00
|
|
|
|
2021-03-07 14:03:37 +01:00
|
|
|
systemctl enable --quiet ${app}.timer
|
|
|
|
systemctl enable --quiet ${app}_check.timer
|
|
|
|
systemctl enable --quiet ${app}_check_read_data.timer
|
|
|
|
systemctl start ${app}.timer
|
|
|
|
systemctl start ${app}_check.timer
|
|
|
|
systemctl start ${app}_check_read_data.timer
|
2022-03-13 17:45:45 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_script_progression --message="Restoration completed for $app"
|