diff --git a/scripts/backup b/scripts/backup index e69de29..32f7c85 100644 --- a/scripts/backup +++ b/scripts/backup @@ -0,0 +1,17 @@ +#!/bin/bash + +# Exit on command errors and treat unset variables as an error +set -eu + +# See comments in install script +app=phpsysinfo + +# Source YunoHost helpers +. /usr/share/yunohost/helpers + +# Backup sources & data +ynh_backup "/var/www/${app}" "sources" + +# Copy NGINX configuration +domain=$(ynh_app_setting_get "$app" domain) +ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf" "nginx.conf" \ No newline at end of file diff --git a/scripts/restore b/scripts/restore index e69de29..3b25824 100644 --- a/scripts/restore +++ b/scripts/restore @@ -0,0 +1,32 @@ +#!/bin/bash + +# Exit on command errors and treat unset variables as an error +set -eu + +# See comments in install script +app=phpsysinfo + +# Source YunoHost helpers +. /usr/share/yunohost/helpers + +# Retrieve old app settings +domain=$(ynh_app_setting_get "$app" domain) +path=$(ynh_app_setting_get "$app" path) + +# Check domain/path availability +sudo yunohost app checkurl "${domain}${path}" -a "$app" \ + || ynh_die "Path not available: ${domain}${path}" + +# Restore sources & data +final_path="/var/www/${app}" +sudo cp -a ./sources "$final_path" + +# Restore permissions to app files +# you may need to make some file and/or directory writeable by www-data (nginx user) +sudo chown -R root:root "$final_path" + +# Restore NGINX configuration +sudo cp -a ./nginx.conf "/etc/nginx/conf.d/${domain}.d/${app}.conf" + +# Restart webserver +sudo service nginx reload \ No newline at end of file