diff --git a/scripts/backup b/scripts/backup index 00c9e31..6249db0 100755 --- a/scripts/backup +++ b/scripts/backup @@ -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 + diff --git a/scripts/remove b/scripts/remove index 6850b14..8b9c61a 100755 --- a/scripts/remove +++ b/scripts/remove @@ -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 diff --git a/scripts/restore b/scripts/restore index 7df2c53..876dd83 100755 --- a/scripts/restore +++ b/scripts/restore @@ -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)