diff --git a/README.md b/README.md index e9ac60b..c85c145 100644 --- a/README.md +++ b/README.md @@ -14,13 +14,13 @@ Help for dev/testing hightly appreciated :) ## Current features * Install / remove scripts + * Backup/restore scripts * Adding / removing a link * Upgrade *not tested* ## TODO * Configure Shaarli during installation - * Add backup/restore scripts * Test more the package ## Changelog diff --git a/manifest.json b/manifest.json index babde23..0fb8556 100644 --- a/manifest.json +++ b/manifest.json @@ -38,7 +38,7 @@ "fr": "Est-ce un site Shaarli public ?" }, "choices": ["Yes", "No"], - "default": "Yes" + "default": "No" }, { "name": "title", diff --git a/scripts/backup b/scripts/backup new file mode 100644 index 0000000..8408871 --- /dev/null +++ b/scripts/backup @@ -0,0 +1,20 @@ +#!/bin/bash + +# Exit on command errors and treat unset variables as an error +set -eu + +# See comments in install script +app=$YNH_APP_INSTANCE_NAME + +# Source YunoHost helpers +source /usr/share/yunohost/helpers + +# Backup sources & data +# Note: the last argument is where to save this path, see the restore script. +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" + + diff --git a/scripts/restore b/scripts/restore new file mode 100644 index 0000000..33a9ee1 --- /dev/null +++ b/scripts/restore @@ -0,0 +1,35 @@ +#!/bin/bash + +# Note: each files and directories you've saved using the ynh_backup helper +# will be located in the current directory, regarding the last argument. + +# Exit on command errors and treat unset variables as an error +set -eu + +# See comments in install script +app=$YNH_APP_INSTANCE_NAME + +# Source YunoHost helpers +source /usr/share/yunohost/helpers + +# Retrieve old app settings +domain=$(ynh_app_setting_get "$app" domain) +path_url=$(ynh_app_setting_get "$app" path) + +# Check domain/path availability +sudo yunohost app checkurl "${domain}${path_url}" -a "$app" \ + || ynh_die "Path not available: ${domain}${path_url}" + +# Restore sources & data +src_path="/var/www/${app}" +sudo cp -a ./sources "$src_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 www-data:www-data "$src_path" + +# Restore NGINX configuration +sudo cp -a ./nginx.conf "/etc/nginx/conf.d/${domain}.d/${app}.conf" + +# Restart webserver +sudo service nginx reload