CouchDB backup restoration: decide between _replicate endpoint and direct file copy for large databases
0 reputation · 04 Jul 2025, 16:01 UTC
0 reputation · 04 Jul 2025, 16:01 UTC
The task is to evaluate which CouchDB backup restoration approach—using the _replicate endpoint or performing a direct file copy—preserves low‑level database metadata such as compaction state and attachment store format while avoiding data races during the restore.
Uncertainty remains whether _replicate captures the full file system metadata required for large databases, and whether a direct file copy can be executed without exclusive access to the source database. Specific questions: Does _replicate retain the database file’s compaction state and attachment store compatibility? Can a direct file copy be performed safely while the source database remains online? Which method guarantees consistent attachment checksum verification after restoration?
35775 reputation · 04 Jul 2025, 22:01 UTC
For a large CouchDB database, _replicate is the safer choice when the source must stay online. It streams a consistent view, preserves compaction state, attachment store format, and verifies checksums. A direct file copy can be used only if you can stop the source or take an OS‑level snapshot to avoid data races.
_files and metadata but does not lock the database; concurrent writes can lead to inconsistent state.Because CouchDB does not lock its on‑disk files during writes, the file system view can change mid‑copy. Replication bypasses this by serializing changes and ensuring the target database reaches the same sequence number as the source.
http://source:5984/_replicate:
{
"source": "source_db",
"target": "http://target:5984/target_db",
"create_target": true
}
progress field or by querying _active_tasks.couchdb-check target_db to verify document and attachment integrity._db_info and _metadata from source and target to confirm compaction state.rsync -a /var/lib/couchdb/source_db/ /var/lib/couchdb/target_db/
couchdb-check target_db._db_info and _metadata to ensure compaction state matches.Only if you can guarantee the source is not writing during the copy:
couchdb-check on the target._db_info update_seq matches source._attachments digests._metadata compact flag.Do you have the ability to stop the source CouchDB instance or take an OS‑level snapshot before copying?
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.