mirror of
https://github.com/YunoHost-Apps/freshrss_ynh.git
synced 2024-09-03 18:36:33 +02:00
Add backup/restore script
This commit is contained in:
parent
9d2f5fc4da
commit
2d90ad808d
2 changed files with 68 additions and 0 deletions
27
scripts/backup
Executable file
27
scripts/backup
Executable file
|
@ -0,0 +1,27 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
# 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)
|
||||
|
||||
# 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/cron.d/${APP} "${BACKUP_DIR}/conf/${APP}"
|
||||
|
||||
# Backup mysql
|
||||
mysqldump -u ${APP} -p$db_pwd ${APP} | sudo dd of=${BACKUP_DIR}/${APP}.dmp
|
||||
|
||||
exit 0
|
41
scripts/restore
Normal file
41
scripts/restore
Normal file
|
@ -0,0 +1,41 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
# 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
|
||||
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: $final_path/data/
|
||||
sudo chown -R www-data: $final_path/extensions/
|
||||
|
||||
# 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/${APP}" /etc/cron.d/${APP}
|
||||
|
||||
# Restore mysql dump
|
||||
sudo su -c "mysql -u ${APP} -p$db_pwd ${APP} < ${BACKUP_DIR}/${APP}.dmp"
|
||||
|
||||
# Reload Nginx, and regenerate SSOwat conf
|
||||
sudo service nginx reload
|
||||
sudo yunohost app ssowatconf
|
||||
|
||||
exit 0
|
Loading…
Reference in a new issue