@@ -13,40 +13,40 @@ DB_IMPORT_FLAGS=''
1313
1414# Determine DB
1515echo " Welcome to the SDIT DB Migrator (mysql/postgres) $NEWLINE "
16- read -rp " Select (mysql|postgres):" DBMODE
16+ read -rp " Select (mysql|postgres):" DB_MODE
1717read -rp " Enter (FROM) port number:" DB_PORT
1818read -rp " Enter (FROM) database name: " DB_NAME
1919read -rp " Enter (TO) port number:" DB_TO_PORT
2020read -rp " Enter (TO) database name: " DB_TO_NAME
2121
22- case $DBMODE in
22+ case $DB_MODE in
23+ mysql|maria|mariadb)
24+ DB_BINARY_NAME=' mysql'
2325
24- mysql|maria|mariadb)
25- DB_BINARY_NAME=' mysql'
26+ # Attempt to connect to DB (FROM and TO).
27+ if ! $DB_BINARY_NAME --host=" ${DB_HOST} " --user=" ${DB_USER} " --password=" ${DB_PASS} " --port=" ${DB_PORT} " -e " use ${DB_NAME} " ; then
28+ echo " Database (FROM) could not be connected ($DB_NAME , $DB_PORT ). Aborting...$NEWLINE "
29+ exit 1
30+ fi
2631
27- # Attempt to connect to DB (FROM and TO).
28- if ! $DB_BINARY_NAME --host=" ${DB_HOST} " --user=" ${DB_USER} " --password=" ${DB_PASS} " --port=" ${DB_PORT} " -e " use ${DB_NAME} " ; then
29- echo " Database (FROM) could not be connected ($DB_NAME , $DB_PORT ). Aborting...$NEWLINE "
30- exit 1;
31- fi
32+ if ! $DB_BINARY_NAME --host=" ${DB_HOST} " --user=" ${DB_USER} " --password=" ${DB_PASS} " --port=" ${DB_TO_PORT} " -e " use ${DB_TO_NAME} " ; then
33+ echo " Database (TO) could not be connected ($DB_TO_NAME , $DB_TO_PORT ). Aborting...$NEWLINE "
34+ exit 1
35+ fi
3236
33- if ! $DB_BINARY_NAME --host=" ${DB_HOST} " --user=" ${DB_USER} " --password=" ${DB_PASS} " --port=" ${DB_TO_PORT} " -e " use ${DB_TO_NAME} " ; then
34- echo " Database (TO) could not be connected ($DB_TO_NAME , $DB_TO_PORT ). Aborting...$NEWLINE "
35- exit 1;
36- fi
37-
38- echo -n " Copying...! $NEWLINE "
39- 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} "
40- echo -n " Copied...! $NEWLINE "
37+ echo -n " Copying...! $NEWLINE "
38+ 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} "
39+ echo -n " Copied...! $NEWLINE "
4140 ;;
4241
43- pg| postgres)
44- echo -n " Postgres support is still in progress. Aborting...$NEWLINE "
42+ pg | postgres)
43+ echo -n " Postgres support is still in progress. Aborting...$NEWLINE "
4544 ;;
4645
47- * )
48- echo -n " This selection is unknown. Aborting...$NEWLINE "
49- exit 1;
46+ * )
47+ echo -n " This selection is unknown. Aborting...$NEWLINE "
48+ exit 1
49+ ;;
5050esac
5151
52- exit 0;
52+ exit 0
0 commit comments