From 43db84f4adb1bfe95178915598ca876dfca66adc Mon Sep 17 00:00:00 2001 From: opi Date: Sat, 7 May 2016 01:44:03 +0200 Subject: [PATCH] [enh] Use latest backup specification. Conflicts: scripts/backup scripts/restore --- scripts/backup | 24 ++++++++++++++---------- scripts/restore | 20 +++++++++++++------- 2 files changed, 27 insertions(+), 17 deletions(-) diff --git a/scripts/backup b/scripts/backup index fa6583b..cfc71a3 100644 --- a/scripts/backup +++ b/scripts/backup @@ -1,15 +1,19 @@ #!/bin/bash app=jappix -# The parameter $1 is the backup directory location -# which will be compressed afterward -backup_dir=$1/apps/$app -mkdir -p $backup_dir +# causes the shell to exit if any subcommand or pipeline returns a non-zero status +set -e -# Backup sources & data -sudo cp -a /var/www/$app/. $backup_dir/sources +# Source YNH helpers +. /usr/share/yunohost/helpers -# Copy Nginx and YunoHost parameters to make the script "standalone" -sudo cp -a /etc/yunohost/apps/$app/. $backup_dir/yunohost -domain=$(sudo yunohost app setting $app domain) -sudo cp -a /etc/nginx/conf.d/$domain.d/$app.conf $backup_dir/nginx.conf \ No newline at end of file +app=${!#} + +# Retrieve app settings +domain=$(sudo yunohost app setting "$app" domain) + +# Save sources & data +ynh_backup "/var/www/${app}" "sources" + +# Copy NGINX configuration +ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf" "nginx.conf" diff --git a/scripts/restore b/scripts/restore index c5ff657..f485e86 100644 --- a/scripts/restore +++ b/scripts/restore @@ -1,16 +1,22 @@ #!/bin/bash app=jappix -# The parameter $1 is the uncompressed restore directory location -backup_dir=$1/apps/$app +# causes the shell to exit if any subcommand or pipeline returns a non-zero status +set -e + +app=${!#} + +# Retrieve arguments +backup_dir=$1 + +# Retrieve old app settings +domain=$(sudo yunohost app setting "$app" domain) # Restore sources & data -sudo cp -a $backup_dir/sources/. /var/www/$app +sudo cp -a "./sources" "/var/www/$app" -# Restore Nginx and YunoHost parameters -sudo cp -a $backup_dir/yunohost/. /etc/yunohost/apps/$app domain=$(sudo yunohost app setting $app domain) -sudo cp -a $backup_dir/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf +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 +sudo service nginx reload