mirror of
https://github.com/YunoHost-Apps/dotclear2_ynh.git
synced 2024-09-03 18:26:29 +02:00
Ajout de la sauvegarde/suppression/restauration de la base dans les scripts backup/remove/restore
This commit is contained in:
parent
2526eeae05
commit
c0fc341316
3 changed files with 15 additions and 2 deletions
|
@ -8,10 +8,15 @@ app=dotclear2
|
|||
backup_dir=$1/apps/$app
|
||||
sudo mkdir -p $backup_dir
|
||||
|
||||
# Backup sources & data
|
||||
# Backup sources
|
||||
sudo cp -a /var/www/$app/. $backup_dir/sources
|
||||
|
||||
# Backup database
|
||||
db_password=$(sudo yunohost app setting $app db_password)
|
||||
sudo mysqldump -u $app -p"$db_password" $app > $backup_dir/dump.sql
|
||||
|
||||
# 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
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ domain=$(sudo yunohost app setting $app domain)
|
|||
path=$(sudo yunohost app setting $app path)
|
||||
admin=$(sudo yunohost app setting $app admin)
|
||||
is_public=$(sudo yunohost app setting $app is_public)
|
||||
root_pwd=$(sudo cat /etc/yunohost/mysql)
|
||||
|
||||
# Remove sources
|
||||
sudo rm -rf /var/www/$app
|
||||
|
@ -15,6 +16,9 @@ sudo rm -rf /var/www/$app
|
|||
# Remove configuration files
|
||||
sudo rm -f /etc/nginx/conf.d/$domain.d/$app.conf
|
||||
|
||||
# Remove database
|
||||
mysql -u root -p$root_pwd -e "DROP DATABASE $app ; DROP USER $app@localhost ;"
|
||||
|
||||
# Restart services
|
||||
sudo service nginx reload
|
||||
sudo yunohost app ssowatconf
|
||||
|
|
|
@ -6,9 +6,13 @@ app=dotclear2
|
|||
# The parameter $1 is the uncompressed restore directory location
|
||||
backup_dir=$1/apps/$app
|
||||
|
||||
# Restore sources & data
|
||||
# Restore sources
|
||||
sudo cp -a $backup_dir/sources/. /var/www/$app
|
||||
|
||||
# Restore database
|
||||
db_password=$(sudo yunohost app setting $app db_password)
|
||||
sudo yunohost app initdb $app -p "$db_password" -s $backup_dir/dump.sql
|
||||
|
||||
# Restore Nginx and YunoHost parameters
|
||||
sudo cp -a $backup_dir/yunohost/. /etc/yunohost/apps/$app
|
||||
domain=$(sudo yunohost app setting $app domain)
|
||||
|
|
Loading…
Reference in a new issue