1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/ttrss_ynh.git synced 2024-10-01 13:34:46 +02:00

[fix] Backup/restore script with relative backup_dir path.

This commit is contained in:
opi 2016-05-04 14:34:47 +02:00
parent d72b50fa45
commit 52ec646c17
2 changed files with 15 additions and 16 deletions

View file

@ -3,22 +3,21 @@
# The parameter $1 is the backup directory location dedicated to the app # The parameter $1 is the backup directory location dedicated to the app
backup_dir=$1 backup_dir=$1
# The parameter $2 is theid of the app instance # The last parameter is the id of the app instance
app=$2 app=${!#}
domain=$(sudo yunohost app setting $app domain) domain=$(sudo yunohost app setting $app domain)
path=$(sudo yunohost app setting $app path) path=$(sudo yunohost app setting $app path)
# Copy the app files # Copy the app files
final_path=/var/www/$app final_path="/var/www/$app"
sudo mkdir -p ${backup_dir}/var/www sudo cp -a "$final_path" ./www
sudo cp -a $final_path "${backup_dir}/var/www/$app"
# Copy the conf files # Copy the conf files
sudo mkdir -p "${backup_dir}/conf" sudo mkdir -p ./conf
sudo cp -a /etc/nginx/conf.d/$domain.d/$app.conf "${backup_dir}/conf/nginx.conf" sudo cp -a /etc/nginx/conf.d/$domain.d/$app.conf ./conf/nginx.conf
sudo cp -a /etc/cron.d/$app "${backup_dir}/conf/cron" sudo cp -a /etc/cron.d/$app ./conf/cron
# Backup db # Backup db
root_pwd=$(sudo cat /etc/yunohost/mysql) root_pwd=$(sudo cat /etc/yunohost/mysql)
sudo su -c "mysqldump -u root -p$root_pwd --no-create-db $app > ${backup_dir}/db.sql" sudo su -c "mysqldump -u root -p$root_pwd --no-create-db $app > ./db.sql"

View file

@ -4,8 +4,8 @@
# The parameter $1 is the backup directory location dedicated to the app # The parameter $1 is the backup directory location dedicated to the app
backup_dir=$1 backup_dir=$1
# The parameter $2 is the id of the app instance ex: ynhexample__2 # The last parameter is the id of the app instance
app=$2 app=${!#}
# Get old parameter of the app # Get old parameter of the app
domain=$(sudo yunohost app setting $app domain) domain=$(sudo yunohost app setting $app domain)
@ -25,7 +25,7 @@ if [ -d $final_path ]; then
echo "There is already a directory: $final_path " | sudo tee /dev/stderr echo "There is already a directory: $final_path " | sudo tee /dev/stderr
exit 1 exit 1
fi fi
sudo cp -a "${backup_dir}/var/www/$app" $final_path sudo cp -a ./www "$final_path"
# Dependences # Dependences
sudo apt-get install php5-cli -y sudo apt-get install php5-cli -y
@ -33,8 +33,8 @@ sudo apt-get install php5-cli -y
db_pwd=$(sudo yunohost app setting $app mysqlpwd) db_pwd=$(sudo yunohost app setting $app mysqlpwd)
db_user=$app db_user=$app
sudo yunohost app initdb $db_user -p $db_pwd sudo yunohost app initdb $db_user -p $db_pwd
sudo su -c "mysql -u $db_user -p$db_pwd $app < ${backup_dir}/db.sql" sudo su -c "mysql -u $db_user -p$db_pwd $app < ./db.sql"
sudo rm -f "${backup_dir}/db.sql" sudo rm -f "./db.sql"
sudo sed -i -e "s/'DB_USER', *\"[^\"]*\"/'DB_USER', \"$app\"/g" $final_path/config.php sudo sed -i -e "s/'DB_USER', *\"[^\"]*\"/'DB_USER', \"$app\"/g" $final_path/config.php
sudo sed -i -e "s/'DB_NAME', *\"[^\"]*\"/'DB_NAME', \"$app\"/g" $final_path/config.php sudo sed -i -e "s/'DB_NAME', *\"[^\"]*\"/'DB_NAME', \"$app\"/g" $final_path/config.php
@ -56,8 +56,8 @@ if [ -f $conf ]; then
echo "There is already a nginx conf file at this path: $conf " | sudo tee /dev/stderr echo "There is already a nginx conf file at this path: $conf " | sudo tee /dev/stderr
exit 1 exit 1
fi fi
sudo cp -a "${backup_dir}/conf/nginx.conf" $conf sudo cp -a "./conf/nginx.conf" $conf
sudo mv "${backup_dir}/conf/cron" /etc/cron.d/$app sudo mv "./conf/cron" /etc/cron.d/$app
sudo chown root /etc/cron.d/$app sudo chown root /etc/cron.d/$app
# Reload Nginx # Reload Nginx