#! /bin/bash

# causes the shell to exit if any subcommand or pipeline returns a non-zero status
set -e

# definie useful vars
app=bozon
parent_path=/var/www
final_path=$parent_path/$app


#retrieve arguments
save_path=$1
domain=$(sudo yunohost app setting $app domain)

# Backup sources & data
sudo cp -R $final_path $save_path/$app

# Copy Nginx and YunoHost parameters to make the script "standalone"
sudo cp -a /etc/yunohost/apps/$app/. $save_path/yunohost
sudo cp -a /etc/nginx/conf.d/$domain.d/$app.conf $save_path/nginx.conf