From 74115ac7147a200afcf1e8f09dfccd5d158ab184 Mon Sep 17 00:00:00 2001 From: Christoph Date: Sat, 6 Feb 2021 10:37:30 +0100 Subject: [PATCH] restore_nextcloud.sh: minor changes on script output --- restore_nextcloud.sh | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/restore_nextcloud.sh b/restore_nextcloud.sh index 28c91fd..604110e 100755 --- a/restore_nextcloud.sh +++ b/restore_nextcloud.sh @@ -95,6 +95,11 @@ echo_skipped() { echo " [ skipped ]" fi } +echo_wait(){ + if $terminal ; then + echo -en "\033[75G[ \033[5m\033[1m...\033[m ]" + fi +} fatal (){ echo "" echo "" @@ -424,6 +429,31 @@ echo "" DATA_DIR=${WEB_BASE_DIR}/data-${VERSION} INSTALL_DIR=${WEB_BASE_DIR}/nextcloud-${VERSION} +echononl " Restore Database - \033[5m\033[1mmay take a long time\033[m" +echo_wait +if [[ "$DATABASE_TYPE" = 'mysql' ]]; then + #mysql $MYSQL_CREDENTIALS $DATABASE_NAME < \ + # ${WEB_BASE_DIR}/${DATABASE_NAME}-v${RESTORE_VERSION}.${DATE_RESTORE_VERSION}.sql 2> $log_file + sleep 10 + if [[ $? -eq 0 ]]; then + echo_ok + else + echo_failed + fatal "$(cat $log_file)" + fi +elif [[ "$DATABASE_TYPE" = 'postgres' ]]; then + PGPASSWORD=$PSQL_PASS \ + pg_dump $DATABASE_NAME -h $PSQL_SERVER -U $PSQL_USER \ + -f ${WEB_BASE_DIR}/${DATABASE_NAME}-v${RESTORE_VERSION}.${DATE_RESTORE_VERSION}.sql 2> $log_file + if [[ $? -eq 0 ]]; then + echo_ok + else + echo_failed + fatal "$(cat $log_file)" + fi +fi +clean_up 0 + # - Deaktiviere Cronjobs # - _backup_crontab_file=/tmp/crontab_root.${backup_date} @@ -655,7 +685,8 @@ fi # - Restore Database # - -echononl " Restore Database" +echononl " Restore Database - \033[5m\033[1mmay take a long time\033[m" +echo_wait if [[ "$DATABASE_TYPE" = 'mysql' ]]; then mysql $MYSQL_CREDENTIALS $DATABASE_NAME < \ ${WEB_BASE_DIR}/${DATABASE_NAME}-v${RESTORE_VERSION}.${DATE_RESTORE_VERSION}.sql 2> $log_file