couchdiff

A command-line utility to calculate the difference between two Cloudant/CouchDB datbases. It operates in one of three modes

default mode - gets a list of document ids and winning revision tokens for each database and "diffs" them using the diff command. In this mode, if the two databases are deemed equal then they have the same number of documents with the same content up the same revision number. There maybe differences in conflicting revisions. If you are interested in conflict data too, then use --conflict mode.

--quick - gets the count of documents and deleted documents from each database - if they match then the two databases are deemed to be the same. This is the quickest but least accurate mode of operation.

--conflicts - same as default mode but also includes revision tokens of non-winning revisions i.e. conflicts. This is the slowest option because couchdiff has to stream the whole changes feed including the document bodies

--unified - outputs the diff in unified format

This tool relies on two universal command-line tools

sort the *nix command-line tool that sorts text files

diff the *nix` command-line tool that calculates the difference between text files

The output of this tool is the output of the final diff step - the difference between the two databases.

Installation

This is a Node.js app distributed using the npm tool:

> npm install -g couchdiff

Running

To calculate the differences between two databases, call couchdiff with two URLs. The URLs
should include credentials where required, and the database name at the end. Either 'http' or
'https' protocols are supported:

Quick mode

A quicker, but less thorough check can be performed by adding the --quick option:

> couchdiff --quick http://localhost:5984/mydb1 http://localhost:5984/mydb2
Both databases have the same number of docs and deletions

Quick mode only checks the number of documents and deleted documents in each database, not
the revision tokens of each document.

Conflicts mode

A slower, but very thorough check can be performed by adding the --conflicts option which will return differences
in the databases not only on the "winning revisions" but in any conflicted documents too: