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
|
2014-11-23 20:22:15 +01:00
|
|
|
|
2016-02-07 00:56:33 +01:00
|
|
|
# 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"
|
2016-02-08 21:09:26 +01:00
|
|
|
sudo cp -a /var/www/${APP}/. "${BACKUP_DIR}/www"
|
2016-02-07 00:56:33 +01:00
|
|
|
|
|
|
|
# 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"
|
2014-11-23 20:22:15 +01:00
|
|
|
|
2014-12-22 18:57:15 +01:00
|
|
|
# Backup mysql
|
2016-02-07 00:56:33 +01:00
|
|
|
mysqldump -u ${APP} -p$db_pwd ${APP} | sudo dd of=${BACKUP_DIR}/${APP}.dmp
|
|
|
|
|
|
|
|
exit 0
|