Taps. An easy way to quickly migrate data to remote databases

If you’ve been using Heroku, you probably have already seen taps at work.

$ heroku db:pull
$ heroku db:push

Looks familar?

Well that’s basically runs on taps. An open-source implementation for database migration that Heroku released to the open-source community.

8 May 2014 Update: Theres an updated gem called
taps-taps which fixes a couple of bugs
migrating from MySQL to SQLite3 after the original gem was abandoned by the
developers.

So how does it work?

You start a taps server on the remote server that you’d like to either pull/push from.

So in this scenario, I have two databases.

Database A resides on my local development machine (Server A)
Database B resides on my remote production server (Server B)

I need to get my data from Database A to Database B without going through the whole copy to mysqldump, scp, mysqladmin import …

Pre-requisite

  1. You need both taps installed on both local and remote machines.
$ gem install taps

So lets get started:

####1. Lets setup the taps server on Server B.

Assuming, I’m using mysql (or mysql2’s adapter) you should adjust the protocol below accordingly. If you’re using postgres/sqlite3, you know what to do.

$ taps server mysql2://database_b_db_user:database_b_db_password@localhost/database_b <a httpuser login name you choose> <a httpasswd you choose>

This will setup a taps server at the default port 5000.

####2. Lets start pushing!

####3. On Server A (your development machine),


$ taps push mysql2://database_a_db_user:database_a_db_password@localhost/database_a http://httpuser:httpasswd@<server_b_ip_address>:5000

And wala!

####4. Pulling data from Database B to A is also just as simple as switching push for pull.

Again, on Server A,

$ taps pull mysql2://database_a_db_user:database_a_db_password@localhost/database_a http://httpuser:httpasswd@<server_b_ip_address>:5000

Hope this helped you as much as it as for me.

As usual, for more information, check out the actual taps documentation.

Easy database migration using taps-taps