1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/kanboard_ynh.git synced 2024-09-03 19:36:17 +02:00

Merge pull request #24 from mbugeia/Dev

rework backup/restore for yunohost 2.4
This commit is contained in:
tostaki 2016-02-08 20:47:21 +01:00
commit afdb0998aa
2 changed files with 44 additions and 28 deletions

View file

@ -1,23 +1,27 @@
#!/bin/bash
set -e
app=kanboard
# The parameter $1 is the backup directory location
# which will be compressed afterward
backup_dir=$1/apps/$app
sudo mkdir -p $backup_dir
sudo chown admin: $backup_dir
# The parameter $1 is the backup directory location dedicated to the app
BACKUP_DIR=$1
# Backup sources & data
sudo cp -a /var/www/$app/. $backup_dir/sources
# 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)
# Backup app files
sudo mkdir -p "${BACKUP_DIR}/www"
sudo cp -a /var/www/${app}/. "${BACKUP_DIR}/www"
# Backup conf files
sudo mkdir -p "${BACKUP_DIR}/conf"
sudo cp -a /etc/nginx/conf.d/$domain.d/${APP}.conf "${BACKUP_DIR}/conf/${APP}.conf"
sudo cp -a /etc/php5/fpm/pool.d/${APP}.conf "${BACKUP_DIR}/conf/php-fpm.conf"
# Backup mysql
db_pwd=$(sudo yunohost app setting $app mysqlpwd)
sudo mysqldump -u $app -p$db_pwd $app > $backup_dir/$app.dmp
mysqldump -u ${APP} -p$db_pwd ${APP} | sudo dd of=${BACKUP_DIR}/${APP}.dmp
# 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
sudo cp -a /etc/php5/fpm/pool.d/$app.conf $backup_dir/php-fpm.conf
exit 0

View file

@ -1,29 +1,41 @@
#!/bin/bash
set -e
app=kanboard
# The parameter $1 is the uncompressed restore directory location
backup_dir=$1/apps/$app
# 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)
# Restore sources & data
sudo cp -a $backup_dir/sources/. /var/www/$app
final_path=/var/www/${APP}
sudo mkdir $final_path
sudo cp -a ${BACKUP_DIR}/www/. $final_path
# Restore permissions
sudo chown -R root:root $final_path
sudo chown -R www-data:www-data $final_path/data
# Restore mysql dump
db_pwd=$(sudo yunohost app setting $app mysqlpwd)
sudo mysql -u $app -p$db_pwd $app < $backup_dir/$app.dmp
# 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
# 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 $backup_dir/php-fpm.conf /etc/php5/fpm/pool.d/$app.conf
# Restore mysql dump
sudo su -c "mysql -u ${APP} -p$db_pwd ${APP} < ${BACKUP_DIR}/${APP}.dmp"
# Reload Nginx, PHP5-FPM and regenerate SSOwat conf
sudo service php5-fpm restart
sudo service nginx reload
sudo yunohost app ssowatconf
sudo yunohost app ssowatconf
exit 0