Skip to content

Commit

Permalink
style: 4spaces, align variable with DB_ prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
iBotPeaches committed Oct 28, 2020
1 parent 1f465ec commit 4692b4c
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions scripts/db_migrate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,40 +13,40 @@ DB_IMPORT_FLAGS=''

# Determine DB
echo "Welcome to the SDIT DB Migrator (mysql/postgres) $NEWLINE"
read -rp "Select (mysql|postgres):" DBMODE
read -rp "Select (mysql|postgres):" DB_MODE
read -rp "Enter (FROM) port number:" DB_PORT
read -rp "Enter (FROM) database name: " DB_NAME
read -rp "Enter (TO) port number:" DB_TO_PORT
read -rp "Enter (TO) database name: " DB_TO_NAME

case $DBMODE in
case $DB_MODE in
mysql|maria|mariadb)
DB_BINARY_NAME='mysql'

mysql|maria|mariadb)
DB_BINARY_NAME='mysql'
# Attempt to connect to DB (FROM and TO).
if ! $DB_BINARY_NAME --host="${DB_HOST}" --user="${DB_USER}" --password="${DB_PASS}" --port="${DB_PORT}" -e "use ${DB_NAME}"; then
echo "Database (FROM) could not be connected ($DB_NAME, $DB_PORT). Aborting...$NEWLINE"
exit 1
fi

# Attempt to connect to DB (FROM and TO).
if ! $DB_BINARY_NAME --host="${DB_HOST}" --user="${DB_USER}" --password="${DB_PASS}" --port="${DB_PORT}" -e "use ${DB_NAME}"; then
echo "Database (FROM) could not be connected ($DB_NAME, $DB_PORT). Aborting...$NEWLINE"
exit 1;
fi
if ! $DB_BINARY_NAME --host="${DB_HOST}" --user="${DB_USER}" --password="${DB_PASS}" --port="${DB_TO_PORT}" -e "use ${DB_TO_NAME}"; then
echo "Database (TO) could not be connected ($DB_TO_NAME, $DB_TO_PORT). Aborting...$NEWLINE"
exit 1
fi

if ! $DB_BINARY_NAME --host="${DB_HOST}" --user="${DB_USER}" --password="${DB_PASS}" --port="${DB_TO_PORT}" -e "use ${DB_TO_NAME}"; then
echo "Database (TO) could not be connected ($DB_TO_NAME, $DB_TO_PORT). Aborting...$NEWLINE"
exit 1;
fi

echo -n "Copying...! $NEWLINE"
mysqldump $DB_EXPORT_FLAGS --user="${DB_USER}" --password="${DB_PASS}" --host="${DB_HOST}" --port="${DB_PORT}" "${DB_NAME}" | mysql $DB_IMPORT_FLAGS --user="${DB_USER}" --password="${DB_PASS}" --host="${DB_HOST}" --port="${DB_TO_PORT}" "${DB_TO_NAME}"
echo -n "Copied...! $NEWLINE"
echo -n "Copying...! $NEWLINE"
mysqldump $DB_EXPORT_FLAGS --user="${DB_USER}" --password="${DB_PASS}" --host="${DB_HOST}" --port="${DB_PORT}" "${DB_NAME}" | mysql $DB_IMPORT_FLAGS --user="${DB_USER}" --password="${DB_PASS}" --host="${DB_HOST}" --port="${DB_TO_PORT}" "${DB_TO_NAME}"
echo -n "Copied...! $NEWLINE"
;;

pg|postgres)
echo -n "Postgres support is still in progress. Aborting...$NEWLINE"
pg | postgres)
echo -n "Postgres support is still in progress. Aborting...$NEWLINE"
;;

*)
echo -n "This selection is unknown. Aborting...$NEWLINE"
exit 1;
*)
echo -n "This selection is unknown. Aborting...$NEWLINE"
exit 1
;;
esac

exit 0;
exit 0

0 comments on commit 4692b4c

Please sign in to comment.