Skip to navigation
Couchdb pull replication doc creating script with databases from a remote couchdb
31.10.17
#!/bin/bash # this will connect to a remote couchdb, get all its databases and create on the local couchdb the replication docs TARGET='127.0.0.1' SOURCE='192.168.0.240' SOURCE_PASS='user:pass' TARGET_PASS='user:pass' #GET json db list from couchdb and convert it into bash string list dbs=$(curl -s 'http://'$SOURCE_PASS'@'$SOURCE':5984/_all_dbs' | python -c "import sys, json; s= ' '.join(json.load(sys.stdin)).replace('_replicator','').replace('_users',''); print(s) ") #manual set of databas elist #dbs='foo bar baz' for DB in $dbs; do _ID=$DB--pull--$SOURCE curl -X PUT http://$TARGET_PASS@127.0.0.1:5984/_replicator/$_ID \ -H "Accept: application/json" \ -H "Content-Type: application/json" \ -d '{"source": "http://'$SOURCE_PASS'@'$SOURCE':5984/'$DB'", "target": "http://'$TARGET_PASS'@'$TARGET':5984/'$DB'" ,"create_target": true,"continuous": true}' done
http://docs.couchdb.org/en/2.1.0/replication/replicator.html
Reply
Anonymous
Information Epoch 1740345469
Think hierarchically.
Home
Notebook
Contact us