Created
February 3, 2019 13:22
-
-
Save asaladino/d372789118fdac73b5ffd7d8cb8fbf3e to your computer and use it in GitHub Desktop.
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
| # Most of this script will work on bash/linux and powershell/windows. | |
| ## Dump SQL to remote location. | |
| ssh user@server.com "mysqldump -P3306 -hmysql.server.com -u dbuser database > contents.sql" | |
| ## Get remote SQL dump file and transfer it locally. | |
| scp -rp user@server.com:/remote/sql/dump/location/contents.sql C:\Temp\ | |
| ## Remove the remote SQL Dump. | |
| ssh user@server.com "rm contents.sql" | |
| ## Powershell only. | |
| ## Replace any strings in the sql dump. | |
| (Get-Content C:\Temp\contents.sql).replace('server.com', 'server.lh') | Set-Content C:\Temp\contents.sql | |
| (Get-Content C:\Temp\contents.sql).replace('https:', 'http:') | Set-Content C:\Temp\contents.sql | |
| ## Load the SQL dump locally. | |
| mysql -u root -P3307 database -e "source C:\Temp\contents.sql" | |
| ## Remove the local SQL Dump. | |
| rm C:\Temp\contents.sql |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment