Raeds rake task to load real-time database (MySQL) into local development database

For many years, I used the ssh pipe from mysqldumpon the real server to mysqlon my development machine to get a copy of the current data.

ssh -C <server> mysqldump --opt <live_database_name> |mysql <local_dev_database_name>

Where it -Callows ssh compression and --optallows speed and completeness.

Does anyone have an equal elliptical rake task? Ideally, the database names will have config / database.yml

+5
source share
5 answers

https://gist.github.com/750129

This is not an elegant solution. This is basically a wrapper for your old method, so it is not even compatible with other database drivers.

, SCM lib/tasks, . config/database.yml. live db, , , Rails.

, .

+4

Postgres: https://gist.github.com/748222.

: db:download, db:replace db:restore. db:restore - .

, - Mysql . , .

+2
+1

, rake , capistrano, capistrano , ..

+1

Theoretically, you should create another "instance" in database.yml (for your live server) and place the correct host there (and leave the rest of the username / password, etc.). In your rake task, you upload the database yaml file, read the host, and continue to work with the command line. It could be easily wrapped in a rake.

0
source

All Articles