Skip to content

Instantly share code, notes, and snippets.

@mt9304
Created January 27, 2019 08:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mt9304/8ce4e9dd86c9bf7883a97d16be522cf6 to your computer and use it in GitHub Desktop.
Save mt9304/8ce4e9dd86c9bf7883a97d16be522cf6 to your computer and use it in GitHub Desktop.
#This scripts creates a dump file from your ClearDB cloud database (Heroku, Wordpress)
#Then changes the siteurl and home columns in the wp_potions table to http://localhost
#Then restores your local MySQL database with this .sql file
#To get host, run herok config --app appname to get the part that looks like us-fewe-wood-south-20.cleardb.net
#Rest can be found in Heroku > app > cleardb > database > stem information
mysqldump --host=changeme --user=changeme --password=changeme heroku_changeme > appname-$(date +%F)-cleardb-to-local.sql
sed -i -e "s/'siteurl','http:\/\/yourappname.herokuapp.com\/'/'siteurl','http:\/\/localhost'/g" appname-$(date +%F)-cleardb-to-local.sql
sed -i -e "s/'home','http:\/\/yourappname.herokuapp.com\/'/'home','http:\/\/localhost'/g" appname-$(date +%F)-cleardb-to-local.sql
mysql --host=localhost --user=root --password=CHANGEME databasename < appname-$(date +%F)-cleardb-to-local.sql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment