Over a million developers have joined DZone.

Copying CouchDB Data Between Laptops

DZone's Guide to

Copying CouchDB Data Between Laptops

Wondering how to copy your CouchDB data between laptops when neither one of those instances is web-accessible? Read on for a quick tip on how to make it happen!

· Database Zone ·
Free Resource

Find out how Database DevOps helps your team deliver value quicker while keeping your data safe and your organization compliant. Align DevOps for your applications with DevOps for your SQL Server databases to discover the advantages of true Database DevOps, brought to you in partnership with Redgate

I'm a regular and happy user of Apache CouchDB — so much so, in fact, that I'm writing a library to talk to it from PHP. While working on tweaking a feature, I realized that the laptop I use for development didn't have the right/enough data on it to test this particular thing — but that I did have a suitable database on my other laptop. Copying data between CouchDB installations is very easy because it has an HTTP API, but usually, when I do this, at least one endpoint is web-accessible. Enter one of my favorite tools: ngrok.

Ngrok allows me to make the CouchDB on one machine visible to the world (with all the security caveats that this entails — it's a random URL, so never leave the tunnel open longer than you need it, etc.) with a command like this:

ngrok http 5984

This opens a tunnel to my local machine on port 5984, which is CouchDB's default port. I'm running a local dev instance that doesn't need a username or password, which makes this simpler if not exactly secure. I get a gobbledeegook ngrok URL that will allow anyone, anywhere to talk to my CouchDB.

Then, I went ahead and, on the other laptop, used the web interface to start replication from the sample products database on the local machine over to the one on the ngrok URL.

Image title

As soon as it starts, the first laptop shows that there's traffic coming over the ngrok link — and a few minutes later, I had the database I wanted and could go ahead and work on this feature.

Align DevOps for your applications with DevOps for your SQL Server databases to increase speed of delivery and keep data safe. Discover true Database DevOps, brought to you in partnership with Redgate

database ,tutorial ,couchdb ,accessibility ,ngrok

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}