CouchDB Dump - Same basic concept as mysqldump, but for CouchDB

I love working with CouchDB. It's a great database with exceptionally strong replication features (even master - master replication!).

That replication feature makes it easy to quickly copy a database. You can run a quick one-off replication to copy a database for backup up, or to move a database from one server to another.

In some cases however, I have found myself missing the ability to be able to easily dump the documents in a database to a file, which I can later easily load back in. The two main cases where I tend to want to do this are:

  • When I want to make periodic snapshots of a database to store in a file on disk, as opposed to running a full continuous replica of a database using the built in replication features.
  • When I need to move a database to a new server but the source and target CouchDBs can not communicate due to intervening firewalls, or being on "internal" networks with no inbound access permitted.

In the cases like the ones above, I sometimes miss the functionality that is available when working with MySQL databases through the mysqldump command. So I did a little research and found the following tools that can be helpful.

I also wrote one myself with Node.js. It is also called couchdb-dump. It is a command line tool that outputs all documents in a CouchDB database. Also included is a command line tool that takes that output as input and loads it back into a CouchDB database.

This tool is published on NPM so installation is as simple as:

npm install couchdb-dump -g

The repo is on GitHub.

Hopefully you will find it useful. Cheers!