Still looking if there is better way to do this (and I bet there it is :), but until I realize, add to top of deploy.rb:
# Get file remote_path from FIRST server targetted by
# the current task and transfer it to local machine as path, SFTP required
def actor.get(remote_path, path, options = {})
execute_on_servers(options) do |servers|
self.sessions[servers.first].sftp.connect do |tsftp|
logger.info "Get #{remote_path} to #{path}"
tsftp.get_file remote_path, path
end
end
end
Sample recipe to get production log from server:
task :download_log, :roles => :web, :only => { :primary => true } do
get "#{deploy_to}/current/log/production.log",
"log/production.log.web" //download server log
end
2 comments
This is sweet. I use this for production logs and my database backup files
newer versions of cap have download, seems to work the same way…
Speak your mind: