Permalink
Browse files

ruby script to replicate to local couchdb

  cp config/config_sample.yml config/config.yml

Edit username and password for access to your 
local couchdb instance.

  ./bin/replicate-couchdb.rb

Will replicate the smartgraphs content from the dev 
couchdb instance to your local couchdb instance.
  • Loading branch information...
1 parent c594a09 commit ac65f119e73fbbb26b1339bab73222af2d4599d5 @stepheneb stepheneb committed Nov 16, 2010
Showing with 34 additions and 0 deletions.
  1. +1 −0 .gitignore
  2. +30 −0 bin/replicate-couchdb.rb
  3. +3 −0 config/config_sample.yml
View
@@ -13,3 +13,4 @@ server.pid.lock
apps/smartgraphs/activity_json/push.sh
apps/smartgraphs/activity_json/update.sh
apps/smartgraphs/activity_json/couch.txt
+config/config.yml
View
@@ -0,0 +1,30 @@
+#!/usr/bin/env ruby
+
+require 'yaml'
+
+APP_ROOT = File.expand_path('../..', __FILE__)
+CONFIG_PATH = File.join(APP_ROOT, 'config')
+
+JRUBY = (defined? RUBY_ENGINE and RUBY_ENGINE[/(java|jruby)/])
+
+begin
+ CONFIG = YAML.load_file(File.join(CONFIG_PATH, 'config.yml'))
+rescue Errno::ENOENT
+ msg = <<-HEREDOC
+
+
+*** missing config/config.yml
+
+ cp config/config_sample.yml config/config.yml
+
+ and enter your local couchdb username and password
+
+ HEREDOC
+ raise msg
+end
+
+username = CONFIG[:couchdb_local_username]
+password = CONFIG[:couchdb_local_password]
+
+cmd = %Q|curl -i -H 'Content-Type: application/json' -X POST -d '{"source":"http://couchdb.cosmos.concord.org/smartgraphs","target":"http://#{username}:#{password}@127.0.0.1:5984/smartgraphs"}' http://127.0.0.1:5984/_replicate|
+system(cmd)
View
@@ -0,0 +1,3 @@
+---
+:couchdb_local_username: username
+:couchdb_local_password: password

0 comments on commit ac65f11

Please sign in to comment.