Capistrano recipes for deploying databases and other common tasks (managing database.yml, importing/exporting/transfering databases, SSH authorization etc.)
- Adds database transfer recipes (via
Taps) - Authorize SSH access
- Manage
database.yml(Soon.)
Taps is great, but having to SSH into my deployment to run the Taps server, as well as
figure out the proper local/remote database urls, is a pain. I knew the Heroku gem
had it figured out; I present the Capistrano friendly version.
If you are new to Taps, check out this introduction to Taps by Adam Wiggins.
gem install cap-taffy
Dependency: The
Tapsgem is required on any server(s) you'll be transferring databases to (:approle) including your development machine (where you'll be runningcaptasks from). Run:
gem install taps
Dependency: The
Herokugem is required on your development machine.
gem install heroku
To start, add the following to your Capfile
require 'cap-taffy/db'
Taffy will start a Taps server on port 5000 by default, so make sure port 5000 (or w/e port you end up using) is open on your :app server(s)
Then you can use:
cap db:push # Or to specify a different port: cap db:push -s taps_port=4321
cap db:pull # Or to specify a different port: cap db:pull -s taps_port=4321
Some of you may not be able/want to open up ports on your servers. Instead, you can run:
ssh -N -L[port]:127.0.0.1:[port] [user]@[remote-server]And then run:
cap db:push -s taps_port=[port] -s local=trueSubstituing the appropriate values for [port], [user], and [remote-server].
ssh -N -L4321:127.0.0.1:4321 henry@load-test cap db:push -s taps_port=4321 -s local=true
Add the following to your Capfile
require 'cap-taffy/ssh'
Using a public key generated from ssh-keygen (e.g. ssh-keygen -t rsa), to authorize access:
cap ssh:authorize # authorizes local public key for SSH access to remote server(s)
Much needed and coming soon.
Thanks to developers of the Taps gem and the Heroku gem. And of course, Capistrano, awesome!