Migrating CouchDB data to a new server

The best way to migrate a couchdb database to a new server is via replication.

However sometimes the data is huge. We need to delivery only some of the original documents to the new server.

In this case we can use the filters for replicating the database. Here is an example to use the filters i.e. using an already existing view using PHP-on-Couch:

require_once "lib/couch.php";
require_once "lib/couchClient.php";
require_once "lib/couchDocument.php";
require_once "lib/couchReplicator.php";

if (couchClient::isValidDatabaseName($current_db_name)) {
    $userdomaindb = new couchClient($current_db_dsn, $current_db_name);
} else {
    echo ("Unable to open CouchDb " . $current_db_name);
}