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.
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.
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.
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.
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.
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With