Updated database script to make it more robust and not break the freaking database when you apply the prod DB to dev
This commit is contained in:
parent
848c86327a
commit
00500ecc33
@ -12,6 +12,7 @@ echo '-------'
|
|||||||
BACKUPDIR="/home/mab/databaseBackupSolidScribe"
|
BACKUPDIR="/home/mab/databaseBackupSolidScribe"
|
||||||
#DEVDBPASS="Crama!Lama*Jamma###88383!!!!!345345956245i"
|
#DEVDBPASS="Crama!Lama*Jamma###88383!!!!!345345956245i"
|
||||||
DEVDBPASS="RootPass1234!"
|
DEVDBPASS="RootPass1234!"
|
||||||
|
# LazaLinga&33Can't!Do!That34
|
||||||
|
|
||||||
cd $BACKUPDIR
|
cd $BACKUPDIR
|
||||||
|
|
||||||
@ -28,8 +29,12 @@ gunzip -dkv $LASTZIPPEDFILE
|
|||||||
BACKUPFILE=$(ls -At *.sql | head -n1)
|
BACKUPFILE=$(ls -At *.sql | head -n1)
|
||||||
|
|
||||||
#Fix to replace incompatible DB type
|
#Fix to replace incompatible DB type
|
||||||
echo "Updating table name in $BACKUPFILE"
|
echo "Updating table name in -> $BACKUPFILE"
|
||||||
sed -i $BACKUPFILE -e 's/utf8mb4_0900_ai_ci/utf8mb4_unicode_ci/g'
|
#sed -i $BACKUPFILE -e 's/utf8mb4_0900_ai_ci/utf8mb4_unicode_ci/g'
|
||||||
|
|
||||||
|
#Fix encoding for dev DB and exclude system tables
|
||||||
|
sed -i 's/utf8mb4_0900_ai_ci/utf8mb4_general_ci/g' $BACKUPFILE
|
||||||
|
sed -r '/INSERT INTO `(sys|mysql)`/d' $BACKUPFILE > $BACKUPFILE
|
||||||
|
|
||||||
echo "Removing and syncing static files"
|
echo "Removing and syncing static files"
|
||||||
rm -r /home/mab/ss/staticFiles/*
|
rm -r /home/mab/ss/staticFiles/*
|
||||||
@ -38,8 +43,20 @@ rsync -e 'ssh -p 13328' -hazC --update mab@solidscribe.com:/home/mab/pi/staticFi
|
|||||||
echo "Updating Database"
|
echo "Updating Database"
|
||||||
mysql -u root --password="$DEVDBPASS" < $BACKUPFILE
|
mysql -u root --password="$DEVDBPASS" < $BACKUPFILE
|
||||||
|
|
||||||
|
## Optimize Database Tables
|
||||||
|
# mysqlcheck --all-databases
|
||||||
|
mysqlcheck --all-databases -o -u root --password="$DEVDBPASS" --silent
|
||||||
|
# mysqlcheck --all-databases --auto-repair
|
||||||
|
# mysqlcheck --all-databases --analyze
|
||||||
|
|
||||||
|
# Fix an issues with DB after messing around with it
|
||||||
|
mysql_upgrade -u root --password="$DEVDBPASS"
|
||||||
|
|
||||||
|
#clean up extracted and modified SQL dumps
|
||||||
rm *.sql
|
rm *.sql
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
echo '-------'
|
echo '-------'
|
||||||
echo "Applied Prod database to Dev. LastFile: $BACKUPFILE"
|
echo "Applied Prod database to Dev. LastFile: $BACKUPFILE"
|
||||||
echo '-------'
|
echo '-------'
|
Loading…
Reference in New Issue
Block a user