Created
January 31, 2012 19:07
-
-
Save spiceee/1712244 to your computer and use it in GitHub Desktop.
rake task to sync your development Redis as a slave of your production master
This file contains 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
namespace :redis do | |
desc "start sync redis databases to local" | |
task :start => :environment do | |
uri = URI.parse REDISTOGO_URL | |
redis = Net::Telnet::new("Host" => "localhost", "Port" => 6379, "Prompt" => /\z/n) | |
redis.cmd("CONFIG SET MASTERAUTH #{uri.password}") | |
redis.cmd("SLAVEOF #{uri.host} #{uri.port}") | |
redis.close | |
end | |
desc "stop sync redis databases to local" | |
task :stop => :environment do | |
uri = URI.parse REDISTOGO_URL | |
redis = Net::Telnet::new("Host" => "localhost", "Port" => 6379, "Prompt" => /\z/n) | |
redis.cmd("SLAVEOF NO ONE") | |
redis.close | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment