Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CouchDB backups and cloning the database

We're looking at CouchdDB for a CMS-ish application. What are some common patterns, best practices and workflow advice surrounding backing up our production database?

I'm particularly interested in the process of cloning the database for use in development and testing.

Is it sufficient to just copy the files on disk out from under a live running instance? Can you clone database data between two live running instances?

Advice and description of the techniques you use will be greatly appreciated.

like image 995
Kyle Burton Avatar asked Sep 23 '08 15:09

Kyle Burton


People also ask

How do I backup my CouchDB database?

To back up CouchDB data, use CouchDB replication to back up the data to another CouchDB installation. You can choose between a normal replication in one-shot mode or continuous replications. Back up all CouchDB databases. Use CouchDB replication to recover the backup databases from the backup CouchDB instance.

Where is CouchDB data stored?

Configuration Backups. CouchDB's configuration system stores data in . ini files under the configuration directory (by default, etc/ ). If changes are made to the configuration at runtime, the very last file in the configuration chain will be updated with the changes.

How does CouchDB replication work?

Replication Procedure. During replication, CouchDB will compare the source and the destination database to determine which documents differ between the source and the destination database. It does so by following the Changes Feeds on the source and comparing the documents to the destination.

How does CouchDB store data?

CouchDB stores data as "documents", as one or more field/value pairs expressed as JSON. Field values can be simple things like strings, numbers, or dates; but ordered lists and associative arrays can also be used. Every document in a CouchDB database has a unique id and there is no required document schema.


2 Answers

Another thing to be aware of is that you can copy files out from under a live database. Given that you may have a possibly large database, you could just copy it OOB from your test/production machine to another machine.

Depending on the write load of the machines it may be advisable to trigger a replication after the copy to gather any writes that were in progress when the file was copied. But replication of a few records would still be quicker than replication the entire database.

For reference see: http://wiki.apache.org/couchdb/FilesystemBackups

like image 125
Paul J. Davis Avatar answered Sep 30 '22 18:09

Paul J. Davis


CouchDB supports replication, so just replicate to another instance of CouchDB and backup from there, avoiding disturbing where you write changes to.

https://docs.couchdb.org/en/latest/maintenance/backups.html

You literally send a POST request to your CouchDB instance telling it where to replicate to, and it Works(tm)

EDIT: You can just cp out the .couch files in the data directory from under the running database as long as you can accept the I/O hit.

like image 27
Marc Gear Avatar answered Sep 30 '22 16:09

Marc Gear