Skip to content

Instantly share code, notes, and snippets.

@tmbritton
Created January 28, 2014 05:58
Show Gist options
  • Save tmbritton/8662903 to your computer and use it in GitHub Desktop.
Save tmbritton/8662903 to your computer and use it in GitHub Desktop.
Sync Wordpress files and database
#!/bin/bash
# Sync prod down to local.
rsync -chavzP --stats [email protected]:/remote/path/to/root/wp-content/uploads/ /local/path/to/root/wp-content/uploads/
echo "Creating MySQL dump"
mysqldump -P 3306 -h example.com -u username -pPASSWORD db_name > dump.sql
echo "Importing MySQL dump"
mysql -u root -proot -h 127.0.0.1 db_name < dump.sql
echo "Executing SQL commands"
mysql -u root -proot -e "UPDATE wp_options SET option_value = 'http://local.example.com' WHERE option_id = 1 OR option_id = 37" db_name
rm dump.sql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment