Skip to content

Instantly share code, notes, and snippets.

@jchris
Created March 15, 2009 02:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jchris/79269 to your computer and use it in GitHub Desktop.
Save jchris/79269 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'couchrest'
# this is the CouchDB where all the old databases are
OLD_HOST = "http://127.0.0.1:5984"
# this is the CouchDB we want to copy to
NEW_HOST = "http://127.0.0.1:5985"
old_couch = CouchRest.new(OLD_HOST)
new_couch = CouchRest.new(NEW_HOST)
databases = old_couch.databases
databases.each do |dbname|
if new_couch.databases.include?(dbname)
puts "the database '#{dbname}' already exists on the target"
puts "patches welcome for picking this process up in the middle"
puts "for now if it fails in the middle you could just comment out these lines"
puts "but you'll do double work and end up with spurious conflicts"
puts
puts
else
upgrader = CouchRest::Upgrade.new(dbname, old_couch, new_couch)
upgrader.clone!
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment