2014-11-23 20:22:15 +01:00
|
|
|
#!/bin/bash
|
2015-10-23 16:24:30 +02:00
|
|
|
|
|
|
|
set -e
|
2014-11-23 20:22:15 +01:00
|
|
|
|
2016-02-07 00:56:33 +01:00
|
|
|
# The parameter $1 is the backup directory location dedicated to the app
|
|
|
|
BACKUP_DIR=$1
|
|
|
|
|
|
|
|
# The parameter $2 is the id of the app instance ex: strut__2
|
|
|
|
APP=$2
|
|
|
|
|
|
|
|
# retrieve useful param
|
|
|
|
domain=$(sudo yunohost app setting ${APP} domain)
|
|
|
|
db_pwd=$(sudo yunohost app setting ${APP} mysqlpwd)
|
|
|
|
path=$(sudo yunohost app setting ${APP} path)
|
|
|
|
|
|
|
|
# Check domain/path availability
|
|
|
|
sudo yunohost app checkurl $domain$path -a ${APP} \
|
|
|
|
|| (echo "Path not available: $domain$path" && exit 1)
|
2014-11-23 20:22:15 +01:00
|
|
|
|
|
|
|
# Restore sources & data
|
2016-02-07 00:56:33 +01:00
|
|
|
final_path=/var/www/${APP}
|
|
|
|
sudo mkdir $final_path
|
|
|
|
sudo cp -a ${BACKUP_DIR}/www/. $final_path
|
2014-11-23 20:22:15 +01:00
|
|
|
|
2015-10-26 14:49:22 +01:00
|
|
|
# Restore permissions
|
|
|
|
sudo chown -R root:root $final_path
|
|
|
|
sudo chown -R www-data:www-data $final_path/data
|
|
|
|
|
2016-02-07 00:56:33 +01:00
|
|
|
# Restore conf files
|
|
|
|
sudo cp -a "${BACKUP_DIR}/conf/${APP}.conf" /etc/nginx/conf.d/$domain.d/${APP}.conf
|
|
|
|
sudo cp -a "${BACKUP_DIR}/conf/php-fpm.conf" /etc/php5/fpm/pool.d/${APP}.conf
|
2014-12-22 18:57:15 +01:00
|
|
|
|
2016-02-07 00:56:33 +01:00
|
|
|
# Restore mysql dump
|
|
|
|
sudo su -c "mysql -u ${APP} -p$db_pwd ${APP} < ${BACKUP_DIR}/${APP}.dmp"
|
2014-11-23 20:22:15 +01:00
|
|
|
|
2015-10-20 15:44:33 +02:00
|
|
|
# Reload Nginx, PHP5-FPM and regenerate SSOwat conf
|
|
|
|
sudo service php5-fpm restart
|
|
|
|
sudo service nginx reload
|
2016-02-07 00:56:33 +01:00
|
|
|
sudo yunohost app ssowatconf
|
|
|
|
|
|
|
|
exit 0
|