Skip to content

Instantly share code, notes, and snippets.

@spiceee
Created January 31, 2012 19:07
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 spiceee/1712244 to your computer and use it in GitHub Desktop.
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
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