Skip to content

Instantly share code, notes, and snippets.

@dwelch2344
Created November 20, 2013 22:20
Show Gist options
  • Save dwelch2344/7572178 to your computer and use it in GitHub Desktop.
Save dwelch2344/7572178 to your computer and use it in GitHub Desktop.
#!/bin/bash
_old=oldDB
_new=newDB
_user=user1234
_pass=pass1234
_oldDomain=staging.site.com
_newDomain=new.site.com
_db=db.site.com
mysqldump --databases "$_old" --user="$_user" --password="$_pass" --host "$_db" --add-drop-database > "$_file"
sed -e "s/$_old/$_new/g" "$_file" > "$_newFile"
sed -i -e "s/$_oldDomain/$_newDomain/g" "$_newFile"
mysql -u "$_user" -p"$_pass" --host "$DATABASE_SERVER" "$_new" < "$_newFile"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment