Zach Smith
Zach Smith

Reputation: 8961

CouchDB: How to replicate a database with its security settings

I have a database called CouchDB_SomeClient_live. I then have this database replicating to a database CouchDB_SomeClient_live_shadow, which I use to test database operations before doing anything on the live database.

The idea is that at any time the shadow can be deleted and it will be recreated as a copy of the live system. This works fine, but I always manually have to add security settings.

  1. How can I get the shadow to be recreated with the same security settings as the live DB?
  2. How and where are the actual database security settings handled by Couch?

The replication document has the following settings:

{
   "_id": "pull_CouchDB_SomeClient_live_to_shadow",
   "source": "CouchDB_SomeClient_live",
   "target": "CouchDB_SomeClient_live_shadow",
   "create_target": true,
   "continuous": true,
   "user_ctx": {
       "name": "admin",
       "roles": [
           "_admin"
       ]
   },
   "owner": "zach"
}

Upvotes: 0

Views: 447

Answers (1)

redgeoff
redgeoff

Reputation: 3341

You can use a command line script to copy the security settings, e.g.

curl -H 'Content-Type: application/json' -H 'Accept: application/json' -X PUT http://admin:admin_password@localhost:5984/foo/_security -d $(curl -X GET admin:admin_password@localhost:5984/foo/_security)

Source: CouchDB full replication

Upvotes: 1

Related Questions