From 73668f25a3ad52663e49a3a16b4de9b58cafca00 Mon Sep 17 00:00:00 2001 From: Ankur Agarwal Date: Tue, 14 May 2013 12:13:43 +0530 Subject: [PATCH 1/2] Added support for custome port as well --- lib/capistrano/mysqldump.rb | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/capistrano/mysqldump.rb b/lib/capistrano/mysqldump.rb index 8244da1..397194a 100644 --- a/lib/capistrano/mysqldump.rb +++ b/lib/capistrano/mysqldump.rb @@ -4,9 +4,9 @@ dump import end - + task :setup do - set :mysqldump_config, YAML.load_file("config/database.yml")[rails_env.to_s] + set :mysqldump_config, YAML.load_file("config/database.yml")[rails_env.to_s] host = mysqldump_config["host"] # overwrite these if necessary @@ -24,12 +24,13 @@ end task :dump, :roles => :db do - setup - username, password, database, host = mysqldump_config.values_at *%w( username password database host ) + setup + username, password, database, host, port = mysqldump_config.values_at *%w( username password database host port) mysqldump_cmd = "%s --quick --single-transaction" % mysqldump_bin mysqldump_cmd += " -h #{host}" if host && !host.empty? - + mysqldump_cmd += " -P #{port}" if port && !port.to_s.empty? + case mysqldump_location when :remote mysqldump_cmd += " -u %s -p %s" % [ username, database ] @@ -41,13 +42,15 @@ download mysqldump_remote_filename, mysqldump_local_filename_gz, :via => :scp run "rm #{mysqldump_remote_filename}" - + + puts "gunzip #{mysqldump_local_filename_gz}" `gunzip #{mysqldump_local_filename_gz}` when :local mysqldump_cmd += " -u %s" % username mysqldump_cmd += " -p#{password}" if password && !password.empty? mysqldump_cmd += " %s > %s" % [ database, mysqldump_local_filename] + puts mysqldump_cmd `#{mysqldump_cmd}` end end From 496fe5ba8016215053f8851dc75ba1da719b7338 Mon Sep 17 00:00:00 2001 From: Ankur Agarwal Date: Sat, 8 Jun 2013 05:46:21 +0530 Subject: [PATCH 2/2] Fixed the bug related to rails server crash --- lib/capistrano/mysqldump.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/capistrano/mysqldump.rb b/lib/capistrano/mysqldump.rb index 397194a..80a474a 100644 --- a/lib/capistrano/mysqldump.rb +++ b/lib/capistrano/mysqldump.rb @@ -1,4 +1,4 @@ -Capistrano::Configuration.instance.load do +Capistrano::Configuration.instance(true).load do namespace :mysqldump do task :default, :roles => :db do dump