Revision: 19909
                            
                                                            
                                    
                                        
Initial Code
                                    
                                    
                                                            
                                    
                                        
Initial URL
                                    
                                    
                                
                                                            
                                    
                                        
Initial Description
                                    
                                    
                                                            
                                    
                                        
Initial Title
                                    
                                    
                                                            
                                    
                                        
Initial Tags
                                    
                                    
                                                            
                                    
                                        
Initial Language
                                    
                                    
                                                    
                        at November 3, 2009 11:40 by nate63179
                            
                            Initial Code
namespace :db do
task :sync_to_local, :roles => :web do
  sql_out = "#{environment_database}.sql"
  run "mysqldump --user #{dbuser} --password=#{dbpass} #{environment_database} > #{sql_out}"
  system "sftp #{user}@myhost.com:#{sql_out} /tmp/#{sql_out}"
  run "rm #{sql_out}"
  system "mysql -u #{dbuser} --password=#{dbpass} mydatabase_development < /tmp/#{sql_out}"
  system "rm /tmp/#{sql_out}"
end
end
# invoked: cap production db:sync_to_local
                                Initial URL
Initial Description
This could be further abstracted to work with other db's. Also, it really should be using Ruby's Tempfile class instead of assuming the local machine is *NIX based, but it works :)
Initial Title
Capistrano: Synchronize local mysql database to remote mysql database
Initial Tags
mysql, rails, ruby
Initial Language
Rails