2017-04-28 17:46:46 +02:00
|
|
|
#!/bin/bash
|
|
|
|
set -eu
|
|
|
|
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
2021-01-04 00:58:31 +01:00
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
2017-04-28 17:46:46 +02:00
|
|
|
domain=$(ynh_app_setting_get $app domain)
|
|
|
|
path=$(ynh_app_setting_get $app path)
|
2017-05-04 14:24:02 +02:00
|
|
|
helper_to_test=$(ynh_app_setting_get $app helper_to_test)
|
|
|
|
|
|
|
|
# Test the 2 alternatives to restore
|
|
|
|
if [ "$helper_to_test" == "ynh_restore" ]; then
|
|
|
|
# Restore all backuped files
|
|
|
|
ynh_restore
|
|
|
|
else
|
|
|
|
# Restore www directory
|
|
|
|
ynh_restore_file /var/www/$app
|
|
|
|
|
|
|
|
# Restore nginx conf
|
|
|
|
ynh_restore_file /etc/nginx/conf.d/$domain.d/$app.conf
|
|
|
|
|
|
|
|
# Restore custom file (with different source/destinations)
|
|
|
|
ynh_restore_file /etc/yoloswag /etc/importantfile
|
|
|
|
fi
|
2017-04-28 17:46:46 +02:00
|
|
|
|
|
|
|
# Restore the database
|
|
|
|
db_user=$app
|
2021-01-04 00:58:31 +01:00
|
|
|
db_name=$app
|
2017-04-28 17:46:46 +02:00
|
|
|
db_pwd=$(ynh_app_setting_get $app mysqlpwd)
|
2021-01-04 00:58:31 +01:00
|
|
|
ynh_mysql_setup_db --db_user=$db_name --db_name=$db_name --db_pwd=$db_pwd
|
|
|
|
ynh_mysql_connect_as --user=$db_name --password=$db_pwd --database=$db_name < ./db.sql
|
2017-04-28 17:46:46 +02:00
|
|
|
|
2021-01-04 00:58:31 +01:00
|
|
|
systemctl reload nginx
|