Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(db): more verbosity on importing #2621

Merged
merged 5 commits into from
Jul 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ permalink: /docs/en-US/changelog/
* Improved provisioning output
* VVV will now attempt to test Nginx configs on installation and recover ( #2604 )
* Switched to new launchpad PPA domains with HTTPS ( #2586 )
* Improved the verboseness of the DB import scripts ( #2621 )

### Bug Fixes

Expand Down
4 changes: 3 additions & 1 deletion config/homebin/db_backup
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
set -eo pipefail
set -u

export VVV_LOG=""
if [ -z "${VVV_LOG+x}" ]; then
export VVV_LOG=""
fi

trap 'rm -rf $TMPFIFODIR' EXIT; TMPFIFODIR=$(mktemp -d); mkfifo $TMPFIFODIR/dbnames

Expand Down
24 changes: 16 additions & 8 deletions database/sql/import-sql.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
set -eo pipefail
set -u

export VVV_LOG=""
if [ -z "${VVV_LOG+x}" ]; then
export VVV_LOG=""
fi

source /srv/provision/provision-helpers.sh

Expand Down Expand Up @@ -72,6 +74,7 @@ IFS=$(echo -en "\n\b")
# Parse through each file in the directory and use the file name to
# import the SQL file into the database of the same name
sql_count=$(ls -1 ./*.sql* 2>/dev/null | wc -l)
vvv_info " * Found ${sql_count} database dumps"
if [ "$sql_count" != 0 ]
then
for file in $( ls ./*.sql* )
Expand All @@ -82,6 +85,15 @@ then
db_name=$(basename "${file}" .sql.gz)
fi

# skip these databases
[ "${db_name}" == "mysql" ] && continue;
[ "${db_name}" == "information_schema" ] && continue;
[ "${db_name}" == "performance_schema" ] && continue;
[ "${db_name}" == "sys" ] && continue;
[ "${db_name}" == "test" ] && continue;

vvv_info " * Processing ${db_name} dump"

# if we specified databases, only restore specified ones
if [[ "${#@}" -gt 0 ]]; then
FOUND=0
Expand All @@ -96,13 +108,6 @@ then
fi
fi

# skip these databases
[ "${db_name}" == "mysql" ] && continue;
[ "${db_name}" == "information_schema" ] && continue;
[ "${db_name}" == "performance_schema" ] && continue;
[ "${db_name}" == "sys" ] && continue;
[ "${db_name}" == "test" ] && continue;

if [ "1" == "${FORCE_RESTORE}" ]; then
vvv_info " * Forcing restore of <b>${db_name}</b><info> database, and granting the wp user access"
mysql -e "DROP DATABASE IF EXISTS \`${db_name}\`"
Expand All @@ -121,6 +126,7 @@ then
skip="true"
fi
done

for include in ${include_list[@]}; do
if [ "${include}" == "${db_name}" ]; then
skip="false"
Expand Down Expand Up @@ -160,4 +166,6 @@ else
vvv_success " * No custom databases to import"
fi

vvv_success " * Database importing finished"

IFS=$SAVEIFS