From e98b150387f92b22e9b4f5c1985ae090620f8181 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= Date: Sun, 5 Mar 2017 20:57:54 +0100 Subject: [PATCH] work on backup and restore --- scripts/backup | 2 +- scripts/restore | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/backup b/scripts/backup index 1db5657..902da69 100755 --- a/scripts/backup +++ b/scripts/backup @@ -24,4 +24,4 @@ sudo cp -a /etc/nginx/conf.d/$domain.d/${APP}.conf "${BACKUP_DIR}/conf/${APP}.co sudo cp -a /etc/cron.d/${APP} "${BACKUP_DIR}/conf/${APP}" # Backup mysql -ynh_mysql_dump_db ${APP} > ${BACKUP_DIR}/${APP}.dmp +sudo ynh_mysql_dump_db ${APP} > ${BACKUP_DIR}/${APP}.dmp diff --git a/scripts/restore b/scripts/restore index be7424e..43fcd8c 100644 --- a/scripts/restore +++ b/scripts/restore @@ -7,6 +7,8 @@ BACKUP_DIR=$1 # The parameter $2 is the id of the app instance ex: strut__2 APP=$2 +dbname=$APP +dbuser=$APP # Source app helpers . /usr/share/yunohost/helpers @@ -14,6 +16,7 @@ APP=$2 # retrieve useful param domain=$(ynh_app_setting_get ${APP} domain) path=$(ynh_app_setting_get ${APP} path) +dbpass=$(ynh_app_setting_get ${APP} mysqlpwd) # Check domain/path availability sudo yunohost app checkurl $domain$path -a ${APP} || ynh_die "The path ${domain}${path} is not available for app installation." @@ -33,7 +36,9 @@ sudo cp -a "${BACKUP_DIR}/conf/${APP}.conf" /etc/nginx/conf.d/$domain.d/${APP}.c sudo cp -a "${BACKUP_DIR}/conf/${APP}" /etc/cron.d/${APP} # Restore mysql dump -ynh_mysql_execute_file_as_root "${BACKUP_DIR}/${APP}.dmp" "${APP}" +ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass" +ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" < "${BACKUP_DIR}/${APP}.dmp" + # Reload Nginx, and regenerate SSOwat conf sudo service nginx reload sudo yunohost app ssowatconf