Created
August 16, 2018 08:22
-
-
Save zeloc/2cb7ebdad0439a8e8e90ad8c359bc4d4 to your computer and use it in GitHub Desktop.
ofl import database script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
db_name='ofl_local' | |
remotedb='https://s3-eu-west-1.amazonaws.com/jbgbackups/ofldotcom/ofldotcom.sql.dump.gz' | |
cd /var/www/vhosts/oakfurnitureland.com/production/htdocs | |
wget $remotedb | |
echo "...Unzip ofl database" | |
gunzip ofldotcom.sql.dump.gz | |
mv ofldotcom.sql.dump export.sql | |
echo "...Remove DB (if exists)" | |
/usr/bin/mysqladmin -uroot -proot drop $db_name | |
echo "...Re-add DB" | |
/usr/bin/mysqladmin -hlocalhost -uroot -proot create $db_name | |
echo "...Find and replace on database" | |
sed -i "s|www.oakfurnitureland.com|ofl-local.space48.com|g" ./export.sql | |
sed -i "s|oakfurnitureland.com|ofl-local.space48.com|g" ./export.sql | |
echo "...Import production database to local" | |
/usr/bin/mysql -hlocalhost -uroot -proot $db_name < ./export.sql | |
echo "...Disabling google analytics" | |
mysql -u root -proot -e "UPDATE ofl_local.core_config_data SET value='0' WHERE path='google/analytics/active'" | |
mysql -u root -proot -e "UPDATE ofl_local.core_config_data SET value='0' WHERE path='googletagmanager/googletagmanager/enabled'" | |
echo "...Clean up files on local" | |
rm -f export.sql | |
rm -f ofldotcom.sql.dump | |
rm -f ofldotcom.sql.dump.gz |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment