Skip to content

Instantly share code, notes, and snippets.

@dustin
Created June 18, 2011 22:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dustin/1033557 to your computer and use it in GitHub Desktop.
Save dustin/1033557 to your computer and use it in GitHub Desktop.
Make a couch have all the stuff another couch has.
#!/usr/bin/env python
import sys
import couchdb
if __name__ == '__main__':
srcurl, desturl = sys.argv[1:]
print "from", srcurl, "to", desturl
src = couchdb.Server(srcurl)
dest = couchdb.Server(desturl)
todo = [db for db in src if db[0] != '_']
destrep = dest['_replicator']
docs = []
for db in todo:
print "Doing", db
if db not in dest:
print "Creating..."
dest.create(db)
rk = "clone-" + db
doc = {'_id': rk, 'source': srcurl + db, 'target': db, 'continuous': True,
'user_ctx': { 'roles': [ "_admin" ] }
}
docs.append(doc)
destrep.update(docs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment