coucharchive
============

Dump/restore a whole CouchDB server contents to/from a single tar.gz file.

Useful for making backups, or replicating your database to a secondary test
environment.

Installation
------------

Using pip:

  sudo pip3 install coucharchive

How it works?
-------------

coucharchive spawns a local CouchDB instance locally, using a temporary directory
for storing data and configuration.

When dumping, it replicates your source CouchDB server (i.e. replicates all dbs,
including `_users`) to the fresh local one, then saves and compresses its data
to a tar.gz archive.

When loading, it uncompresses the archive, has the local CouchDB instance use it
as its data, then replicated to your remote CouchDB server.

Examples
--------

Set-up the database server info in `config.ini`:

  [database]
  url = http://my-server.com:5984
  username = root
  password = p4ss

Dumping database to a file:

  coucharchive -c config.ini dump -o /tmp/coucharchive.tar.gz

Restoring database from an archive:

  coucharchive -c config.ini load -i /tmp/coucharchive.tar.gz

Restoring database from another CouchDB server:

  coucharchive -c config.ini replicate \
    --source http://admin:pass@other.server:5984/

Restoring database from an archive in a standalone CouchDB server, without
replicating:

  coucharchive -c config.ini load -i /tmp/coucharchive.tar.gz --standalone-server

Go further
----------

For instance, save a backup to S3 and notify somebody via email:

  aws s3 cp /tmp/archive.tar.gz s3://my-backups/archive.tar.gz
  cat >/tmp/email.txt <<EOM
  Subject: New backup saved on S3

  A CouchDB backup called archive.tar.gz was successfully created and pushed
  on Amazon S3.
  EOM
  sendmail user@example.com </tmp/email.txt
