Created
June 18, 2011 22:17
-
-
Save dustin/1033557 to your computer and use it in GitHub Desktop.
Make a couch have all the stuff another couch has.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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