#!/bin/bash

# The parameter $1 is the backup directory location dedicated to the app
BACKUP_DIR=$1

# The parameter $2 is theid of the app instance ex: strut__2
APP=$2

domain=$(sudo yunohost app setting $APP domain)

# Copy the app files
final_path=/var/www/$APP
sudo cp -a $final_path "${BACKUP_DIR}/www" 

# Copy the conf files
sudo mkdir -p "${BACKUP_DIR}/conf"
sudo cp -a /etc/nginx/conf.d/$domain.d/$APP.conf "${BACKUP_DIR}/conf/nginx.conf"

