I recently bought a mac, and i prefer to my Windows machine, as I wasn’t a fan of Win8. As I don’t keep my databases within my central version control server, I had to manually copy them down from production, to my local machine (to complete my development environment set-up.)
To do this, I had to first get a backup of all my MySQL databases;
mysqldump --all-databases -uroot -p > backup.sql
Now we’ve got a backup of all our MySQL databases, we’re going to want to copy them down into our local machine.
First, we need to create a SSH key on our local machine, and add it to
~/.ssh/authorised_keys on our remote server.
ssh-keygen -t rsa
id_rsa.pubto your clipboard;
So now that we’ve generated our key on our local machine, we need our remote server to authorise it.
Log into your remote server (
ssh [email protected]) and perform the following;
And paste the contents of the clipboard (this is your
id_rsa.pub file) into the file
On our local machine, we can run the following to copy our remote files down to our local machine;
scp -r [email protected]:/path/to/backup /Users/harrydenley/Desktop/
You will be prompted for your RSA key password (from when we generated it earlier), and once confirmed, the files will start to copy down to your local machine!