fix: Non-working bash scripts for mysql dump, db import, and showing recent errors

- bin/mysql-import requires a argument: the filename of the sql dump in ./db folder
This commit is contained in:
Gulácsi András
2023-11-03 22:43:12 +01:00
parent 27f344f3f8
commit 6950b06e85
3 changed files with 21 additions and 3 deletions
+2 -1
View File
@@ -4,4 +4,5 @@ source .env
current_date=`date +"%Y_%m_%d"`
docker exec mysql bash -c "exec mysqldump --databases ${DB_NAME} -uroot -p${DB_ROOT_PASSWORD} > ./db/dump_$(current_date).sql"
docker exec "${APP_NAME}"-db bash -c "exec mysqldump --databases ${DB_NAME} -uroot -p${DB_ROOT_PASSWORD} > ./dump_$current_date.sql"
docker cp "${APP_NAME}"-db:dump_"$current_date".sql ./db/dump_"$current_date".sql
+1 -1
View File
@@ -5,5 +5,5 @@ source .env
echo "==============================================="
echo "MySQL error log:"
echo "==============================================="
docker logs "${APP_NAME}"-mysql --tail "${TAIL_COUNT}" --details
docker logs "${APP_NAME}"-db --tail "${TAIL_COUNT}" --details
exit
+18 -1
View File
@@ -2,4 +2,21 @@
set -a
source .env
docker-compose exec db bash -c "mysql -hdb -uroot -p${DB_ROOT_PASSWORD} ${DB_NAME} < ./db/db.sql"
# IMPORTANT!
# Make sure to have the correct database name in the comments of the sql dump!
# Example:
#-- MySQL dump 10.13 Distrib 8.0.31, for Linux (x86_64)
#--
#-- Host: localhost Database: testdbname
#--
#-- Current Database: `testdbname`
#--
#CREATE DATABASE /*!32312 IF NOT EXISTS*/ `testdbname` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci */ /*!80016 DEFAULT ENCRYPTION='N' */;
#USE `testdbname`;
# The argument is the filename: 'dump_2023_11_03.sql' (must be in the ./db folder of your project root)
filename="$@"
docker cp "./db/$filename" "${APP_NAME}"-db:./"$filename"
docker exec "${APP_NAME}"-db bash -c "mysql -uroot -p${DB_ROOT_PASSWORD} newage < $filename"