Restore CouchDB from .couch files

1.5k Views Asked by At

I'm trying to backup and restore a CouchDB following the official documentation:

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

"However, you can also copy the actual .couch files from the CouchDB data directory (by default, data/) at any time, without problem. CouchDB’s append-only storage format for both databases and secondary indexes ensures that this will work without issue."

Since the doc seems to not show clearly the steps to restore from files, i copy the entire data folder, build up a local CouchDB docker container and try to paste the files into container opt/couchdb/data folder.

But what i get when i start/restart the container and access localhost:5984 to see the databases, is: "This database failed to load."

enter image description here

What should i do after copy the files? Paste directly should work? What is the right time to paste? Should i create the DBs before?

Thank you all

2

There are 2 best solutions below

0
On

i've been able to resolve that way: https://github.com/apache/couchdb/discussions/3436

0
On

I think you may need to update the ownership of the backup files on your docker container.

This fixed the issue for me:

# recursively change ownership of data dir to couchdb:couchdb
docker exec <container_id> bash -c 'chown -R couchdb:couchdb /opt/couchdb/data'

Just replace the <container_id> with your docker container id and the destination with the location of couchdb data directory in your container.