Skip to content

Commit

Permalink
Merge pull request #2621 from Varying-Vagrant-Vagrants/db-import
Browse files Browse the repository at this point in the history
feat(db): more verbosity on importing
  • Loading branch information
tomjn authored Jul 11, 2022
2 parents 6746b75 + 7db48c2 commit 41e7850
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
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

0 comments on commit 41e7850

Please sign in to comment.