Last active
April 25, 2019 07:49
-
-
Save thecancerus/431d77baf8ff5d866fa0e6aa14150b03 to your computer and use it in GitHub Desktop.
prod-to-test.sh
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
#!/usr/bin/env bash | |
# Back up Script to Amazon S3 | |
# Source: | |
# Author: Amit | |
DATE=$(date +%Y%m%d%H%M) | |
LOGFILE=/var/log/prod-restore/$DATE.log | |
EMAIL='' | |
mkdir -p /var/log/prod-restore | |
touch $LOGFILE | |
#rsync code | |
rsync -a [email protected]:/var/www/xyz.net/htdocs/ /var/www/test.xyz.net/htdocs/ | |
#rsync db | |
rsync -a [email protected]:/var/www/xyz.net/db/ /var/www/test.xyz.net/db/ | |
#import db | |
gunzip /var/www/test.xyz.net/db/xyz_net.sql.gz | |
mysql test_walnutedu_net < /var/www/test.xyz.net/db/xyz_net.sql | |
rm /var/www/test.xyz.net/db/xyz_net.sql | |
#run search-replace | |
wp search-replace 'https://xyz.net' 'http://test.xyz.net' --skip-columns=guid --allow-root --path='/var/www/test.xyz.net/htdocs/' | |
wp db query 'UPDATE `wp_postmeta` SET `meta_value` = "[email protected]" WHERE `wp_postmeta`.`meta_key` = "father_email_address"' --allow-root --path='/var/www/test.xyz.net/htdocs/' | |
wp db query 'UPDATE `wp_postmeta` SET `meta_value` = "[email protected]" WHERE `wp_postmeta`.`meta_key` = "mother_email_address"' --allow-root --path='/var/www/test.xyz.net/htdocs/' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment