Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Syncing remote database to local?

Tags:

mysql

sync

local

I'm hoping I can use a shell script that will pull a sql dump down from my production site and into my local database. Ideally, I'd like to be able to run something like this:

sync_site example_com example_local

Where the first argument is the production database and the second is the local database. The remote database is always on the same server, behind SSH, with known MySQL credentials.

like image 441
aaron carlino Avatar asked Feb 03 '23 22:02

aaron carlino


1 Answers

Figured it out:

ssh [email protected] mysqldump -u user -ppass remote_db | mysql -u user -ppass local_db
like image 193
aaron carlino Avatar answered Feb 05 '23 16:02

aaron carlino