Skip to content

Instantly share code, notes, and snippets.

@teledirigido
Created November 14, 2014 00:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save teledirigido/64b280392e52b26f9322 to your computer and use it in GitHub Desktop.
Save teledirigido/64b280392e52b26f9322 to your computer and use it in GitHub Desktop.
MySQL backup on post-merge
#!/bin/bash
# Post-merge hook to add a mysql db when post-merge occurs.
#
## Change the following values to suit your local setup.
# The name of a database user with read access to the database.
DBUSER=[dbuser]
# The password associated with the above user. Leave commented if none.
DBPASS=[dbpass]
# The database associated with this repository.
DBNAME=[dbname]
# The path relative to the repository root in which to store the sql dump.
DBPATH=[dbpath]
# Replace foreign url for new url
PROJECT=[project-name-url]
OLDURL=http://labs.blacksheepdesign.co.nz/$PROJECT/site
NEWURL=http://miguel.dev/$PROJECT/site
mysql -u $DBUSER -p$DBPASS $DBNAME < $DBPATH/$DBNAME.sql
wp search-replace $OLDURL $NEWURL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment