mirror of
https://github.com/YunoHost-Apps/spip_ynh.git
synced 2024-09-03 20:25:59 +02:00
Correction Backup/restore
This commit is contained in:
parent
c06897cecb
commit
4d924b6e3f
2 changed files with 30 additions and 24 deletions
|
@ -11,17 +11,17 @@ source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
# Retrieve app settings
|
# Retrieve app settings
|
||||||
domain=$(ynh_app_setting_get "$app" domain)
|
domain=$(ynh_app_setting_get "$app" domain)
|
||||||
path=$(ynh_app_setting_get "$app" final_path)
|
|
||||||
with_mysql=$(ynh_app_setting_get "$app" with_mysql)
|
with_mysql=$(ynh_app_setting_get "$app" with_mysql)
|
||||||
|
|
||||||
# Copy the app files
|
# Copy the app files
|
||||||
DESTDIR="/var/www/${app}"
|
final_path="/var/www/${app}"
|
||||||
ynh_backup "$DESTDIR" "sources" 1
|
ynh_backup "$final_path" "sources" 1
|
||||||
|
|
||||||
# Copy the conf files
|
# Copy the nginx conf files
|
||||||
ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf" "conf/nginx.conf"
|
ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf" "nginx.conf"
|
||||||
ynh_backup "/etc/php5/fpm/pool.d/${app}.conf" "conf/php-fpm.conf"
|
# Copy the php-fpm conf files
|
||||||
ynh_backup "/etc/php5/fpm/conf.d/20-${app}.ini" "conf/php-fpm.ini"
|
ynh_backup "/etc/php5/fpm/pool.d/${app}.conf" "php-fpm.conf"
|
||||||
|
ynh_backup "/etc/php5/fpm/conf.d/20-${app}.ini" "php-fpm.ini"
|
||||||
|
|
||||||
# Backup db
|
# Backup db
|
||||||
if [[ $with_mysql -eq 1 ]]; then
|
if [[ $with_mysql -eq 1 ]]; then
|
||||||
|
|
|
@ -14,11 +14,15 @@ source /usr/share/yunohost/helpers
|
||||||
domain=$(ynh_app_setting_get $app domain)
|
domain=$(ynh_app_setting_get $app domain)
|
||||||
path=$(ynh_app_setting_get $app path)
|
path=$(ynh_app_setting_get $app path)
|
||||||
is_public=$(ynh_app_setting_get $app is_public)
|
is_public=$(ynh_app_setting_get $app is_public)
|
||||||
final_path=$(ynh_app_setting_get $app final_path)
|
with_mysql=$(ynh_app_setting_get "$app" with_mysql)
|
||||||
|
|
||||||
if [ -d $final_path ]; then
|
# Check domain/path availability
|
||||||
ynh_die "There is already a directory: $final_path"
|
sudo yunohost app checkurl "${domain}${path}" -a "$app" \
|
||||||
fi
|
|| ynh_die "Path not available: ${domain}${path}"
|
||||||
|
|
||||||
|
# Restore sources & data
|
||||||
|
final_path="/var/www/${app}"
|
||||||
|
sudo cp -a ./sources "$final_path"
|
||||||
|
|
||||||
# Check configuration files php-fpm
|
# Check configuration files php-fpm
|
||||||
nginx_conf="/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
nginx_conf="/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
||||||
|
@ -34,23 +38,25 @@ phpfpm_ini="/etc/php5/fpm/conf.d/20-${app}.ini"
|
||||||
"The PHP FPM INI configuration already exists at '${phpfpm_ini}'.
|
"The PHP FPM INI configuration already exists at '${phpfpm_ini}'.
|
||||||
You should safely delete it before restoring this app."
|
You should safely delete it before restoring this app."
|
||||||
|
|
||||||
sudo cp -a ./sources $final_path
|
# Restore db
|
||||||
|
if [[ $with_mysql -eq 1 ]]; then
|
||||||
db_pwd=$(ynh_app_setting_get $app mysqlpwd)
|
db_pwd=$(ynh_app_setting_get $app mysqlpwd)
|
||||||
db_user=$app
|
db_user=$app
|
||||||
ynh_mysql_create_db $db_user $db_user $db_pwd
|
ynh_mysql_create_db $db_user $db_user $db_pwd
|
||||||
sudo su -c "mysql -u $db_user -p$db_pwd $app < ./db.sql"
|
sudo su -c "mysql -u $db_user -p$db_pwd $app < ./db.sql"
|
||||||
sudo rm -f "./db.sql"
|
sudo rm -f "./db.sql"
|
||||||
sudo sed -i -e "s/'DB_USER', *'[^']*'/'DB_USER', '$app'/g" $final_path/config/connect.php
|
sudo sed -i -e "s/'__DB_USER__', *'[^']*'/'__DB_USER__', '$app'/g" $final_path/config/connect.php
|
||||||
sudo sed -i -e "s/'DB_NAME', *'[^']*'/'DB_NAME', '$app'/g" $final_path/config/connect.php
|
# sudo sed -i -e "s/'__DB_PWD__', *'[^']*'/'__DB_PWD__', '$app'/g" $final_path/config/connect.php
|
||||||
|
fi
|
||||||
|
|
||||||
# Set permissions
|
# Set permissions
|
||||||
sudo chown -R www-data: $final_path
|
sudo chown -R www-data: $final_path
|
||||||
|
|
||||||
# Restore configuration files
|
# Restore nginx configuration files
|
||||||
sudo cp -a ./conf/nginx.conf "$nginx_conf"
|
sudo cp -a ./nginx.conf "$nginx_conf"
|
||||||
sudo cp -a ./conf/php-fpm.conf "$phpfpm_conf"
|
# Restore php-fpm configuration files
|
||||||
sudo cp -a ./conf/php-fpm.ini "$phpfpm_ini"
|
sudo cp -a ./php-fpm.conf "$phpfpm_conf"
|
||||||
|
sudo cp -a ./php-fpm.ini "$phpfpm_ini"
|
||||||
|
|
||||||
# Reload services
|
# Reload services
|
||||||
sudo service php5-fpm reload || true
|
sudo service php5-fpm reload || true
|
||||||
|
|
Loading…
Reference in a new issue