Created
August 14, 2009 03:23
-
-
Save cpetersen/167623 to your computer and use it in GitHub Desktop.
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
desc 'backup the production database' | |
task :backup do | |
server = "your server" | |
username = "your user" | |
keypair = "#{Merb.root}/path/to/your/keypair" | |
databases = ["your", "databases", "here" ] | |
ssh_command = "ssh -i #{keypair} -L 5985:localhost:5984 #{username}@#{server}" | |
pid, stdin, stdout, stderr = Open4::popen4 ssh_command | |
sleep(2) # Hack to let the connection finish setting up | |
databases.each do |db| | |
puts "Replicating #{db}" | |
`curl -s -X POST -d '{"source":"http://127.0.0.1:5985/depot-#{db}","target":"production-#{db}"}' http://localhost:5984/_replicate` | |
end | |
`kill #{pid}` | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment