Browse Source

Ajusta scripts p migração em paralelo

pull/1751/merge
Marcio Mazza 7 years ago
parent
commit
f2bcdebc38
  1. 5
      sapl/legacy/scripts/migra_dbs.sh
  2. 12
      sapl/legacy/scripts/migra_um_db.sh

5
sapl/legacy/scripts/migra_dbs.sh

@ -2,8 +2,13 @@
# rodar esse script na raiz do projeto
if [ $# -ge 1 ]; then
# mysql com senha
parallel -eta --verbose -j+0 ./sapl/legacy/scripts/migra_um_db.sh :::: <(mysql -u $1 -p$2 -e 'show databases;' | grep '^sapl_') ::: $1 ::: $2
elif [ $# -ge 0 ]; then
# mysql sem senha
parallel -eta --verbose -j+0 ./sapl/legacy/scripts/migra_um_db.sh :::: <(mysql -u $1 -e 'show databases;' | grep '^sapl_') ::: $1
else
echo "USO:"
echo " $0 <usuário mysql> [senha mysql]"

12
sapl/legacy/scripts/migra_um_db.sh

@ -6,11 +6,13 @@ if [ $# -ge 2 ]; then
# proteje pasta com dumps de alterações acidentais
# chmod -R -w ~/migracao_sapl/sapl_dumps
DIR_MIGRACAO=~/migracao_sapl
DATE=$(date +%Y-%m-%d)
DIR=~/${DATE}_logs_migracao
mkdir -p $DIR
DIR_LOGS=$DIR_MIGRACAO/logs/$DATE
mkdir -p $DIR_LOGS
LOG="$DIR/$1.migracao.log"
LOG="$DIR_LOGS/$1.migracao.log"
rm -f $LOG
echo "########################################" | tee -a $LOG
@ -21,11 +23,11 @@ if [ $# -ge 2 ]; then
if [ $3 ]; then
# se há senha do mysql
mysql -u$2 -p"$3" -N -s -e "DROP DATABASE IF EXISTS $1; CREATE DATABASE $1;"
mysql -u $2 -p "$3" < ~/migracao_sapl/sapl_dumps/$1.sql
mysql -u$2 -p"$3" < $DIR_MIGRACAO/dumps_mysql/$1.sql
else
# se não há senha do mysql
mysql -u$2 -N -s -e "DROP DATABASE IF EXISTS $1; CREATE DATABASE $1;"
mysql -u $2 < ~/migracao_sapl/sapl_dumps/$1.sql
mysql -u$2 < $DIR_MIGRACAO/dumps_mysql/$1.sql
fi;
echo "O banco legado foi restaurado" |& tee -a $LOG
echo >> $LOG

Loading…
Cancel
Save