2020-10-10 14:27:52 -07:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
echo '-------'
|
|
|
|
echo 'Starting Database Restore'
|
|
|
|
echo '-------'
|
|
|
|
|
|
|
|
#get Latest database backup
|
|
|
|
|
|
|
|
# Unzip File
|
|
|
|
# gzip -dk file.gz
|
|
|
|
|
|
|
|
BACKUPDIR="/home/mab/databaseBackupSolidScribe"
|
2021-12-18 14:18:22 -08:00
|
|
|
#DEVDBPASS="Crama!Lama*Jamma###88383!!!!!345345956245i"
|
|
|
|
DEVDBPASS="***REMOVED***"
|
2020-10-10 14:27:52 -07:00
|
|
|
|
|
|
|
cd $BACKUPDIR
|
|
|
|
|
|
|
|
# -t sort by modification time, newest first
|
|
|
|
# -A --almost-all, do not list implied . and ..
|
|
|
|
LASTZIPPEDFILE=$(ls -At *.gz | head -n1)
|
|
|
|
|
|
|
|
# -k keep file after unzip
|
|
|
|
# -d Decompress
|
|
|
|
# -v verbose
|
|
|
|
echo "Unzipping $LASTZIPPEDFILE"
|
|
|
|
gunzip -dkv $LASTZIPPEDFILE
|
|
|
|
|
|
|
|
BACKUPFILE=$(ls -At *.sql | head -n1)
|
|
|
|
|
|
|
|
#Fix to replace incompatible DB type
|
|
|
|
echo "Updating table name in $BACKUPFILE"
|
|
|
|
sed -i $BACKUPFILE -e 's/utf8mb4_0900_ai_ci/utf8mb4_unicode_ci/g'
|
|
|
|
|
|
|
|
echo "Removing and syncing static files"
|
|
|
|
rm -r /home/mab/ss/staticFiles/*
|
|
|
|
rsync -e 'ssh -p 13328' -hazC --update mab@solidscribe.com:/home/mab/pi/staticFiles /home/mab/ss/
|
|
|
|
|
|
|
|
echo "Updating Database"
|
|
|
|
mysql -u root --password="$DEVDBPASS" < $BACKUPFILE
|
2021-02-12 09:11:33 -08:00
|
|
|
|
2020-10-10 14:27:52 -07:00
|
|
|
rm *.sql
|
|
|
|
|
|
|
|
echo '-------'
|
|
|
|
echo "Applied Prod database to Dev. LastFile: $BACKUPFILE"
|
|
|
|
echo '-------'
|