Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

database:dump:remote doesn't work #343

Merged
merged 1 commit into from

2 participants

Daan Poron William Durand
Daan Poron
  • replaced the run blocks for data capturing with the capture method
  • used sh -c around the try_sudo commands to make the the whole command run by the sudo user and not only the part before the |
  • used force delete to skip the 'remove write-protected regular file?' question

related to this issue: #337

Daan Poron daanporon replace run block for data capturing with capture method + make try_s…
…udo work

- replaced the run blocks for data capturing with the capture method
- used sh -c around the try_sudo commands to make the the whole command
run by the sudo user and not only the part before the |
- used force delete to skip the 'remove write-protected regular file?'
question
dce62e3
Daan Poron

closed duplicate issue: #337

William Durand willdurand merged commit 2435a17 into from
William Durand
Collaborator

thanks!

Daan Poron daanporon referenced this pull request in Kunstmaan/kStrano
Closed

find out how to copy the database from remote #10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 16, 2013
  1. Daan Poron

    replace run block for data capturing with capture method + make try_s…

    daanporon authored
    …udo work
    
    - replaced the run blocks for data capturing with the capture method
    - used sh -c around the try_sudo commands to make the the whole command
    run by the sudo user and not only the part before the |
    - used force delete to skip the 'remove write-protected regular file?'
    question
This page is out of date. Refresh to see the latest.
Showing with 15 additions and 21 deletions.
  1. +15 −21 lib/symfony2/database.rb
36 lib/symfony2/database.rb
View
@@ -11,19 +11,16 @@
sqlfile = "#{application}_dump.sql"
config = ""
- run "#{try_sudo} cat #{current_path}/#{app_config_path}/#{app_config_file}" do |ch, st, data|
- config = load_database_config data, symfony_env_prod
- end
+ data = capture("#{try_sudo} cat #{current_path}/#{app_config_path}/#{app_config_file}")
+ config = load_database_config data, symfony_env_prod
case config['database_driver']
when "pdo_mysql", "mysql"
- run "#{try_sudo} mysqldump -u#{config['database_user']} --host='#{config['database_host']}' --password='#{config['database_password']}' #{config['database_name']} | gzip -c > #{file}" do |ch, stream, data|
- puts data
- end
+ data = capture("#{try_sudo} sh -c 'mysqldump -u#{config['database_user']} --host='#{config['database_host']}' --password='#{config['database_password']}' #{config['database_name']} | gzip -c > #{file}'")
+ puts data
when "pdo_pgsql", "pgsql"
- run "#{try_sudo} pg_dump -U #{config['database_user']} #{config['database_name']} --clean | gzip -c > #{file}" do |ch, stream, data|
- puts data
- end
+ data = capture("#{try_sudo} sh -c 'pg_dump -U #{config['database_user']} #{config['database_name']} --clean | gzip -c > #{file}'")
+ puts data
end
FileUtils.mkdir_p("backups")
@@ -33,7 +30,7 @@
rescue Exception # fallback for file systems that don't support symlinks
FileUtils.cp_r("backups/#{filename}", "backups/#{application}.#{env}_dump.latest.sql.gz")
end
- run "#{try_sudo} rm #{file}"
+ run "#{try_sudo} rm -f #{file}"
end
desc "Dumps local database"
@@ -106,23 +103,20 @@
upload(file, "#{remote_tmp_dir}/#{filename}", :via => :scp)
run "#{try_sudo} gunzip -c #{remote_tmp_dir}/#{filename} > #{remote_tmp_dir}/#{sqlfile}"
- run "#{try_sudo} cat #{current_path}/#{app_config_path}/#{app_config_file}" do |ch, st, data|
- config = load_database_config data, symfony_env_prod
- end
+ data = capture("#{try_sudo} cat #{current_path}/#{app_config_path}/#{app_config_file}")
+ config = load_database_config data, symfony_env_prod
case config['database_driver']
when "pdo_mysql", "mysql"
- run "#{try_sudo} mysql -u#{config['database_user']} --host='#{config['database_host']}' --password='#{config['database_password']}' #{config['database_name']} < #{remote_tmp_dir}/#{sqlfile}" do |ch, stream, data|
- puts data
- end
+ data = capture("#{try_sudo} mysql -u#{config['database_user']} --host='#{config['database_host']}' --password='#{config['database_password']}' #{config['database_name']} < #{remote_tmp_dir}/#{sqlfile}")
+ puts data
when "pdo_pgsql", "pgsql"
- run "#{try_sudo} psql -U #{config['database_user']} #{config['database_name']} < #{remote_tmp_dir}/#{sqlfile}" do |ch, stream, data|
- puts data
- end
+ data = capture("#{try_sudo} psql -U #{config['database_user']} #{config['database_name']} < #{remote_tmp_dir}/#{sqlfile}")
+ puts data
end
- run "#{try_sudo} rm #{remote_tmp_dir}/#{filename}"
- run "#{try_sudo} rm #{remote_tmp_dir}/#{sqlfile}"
+ run "#{try_sudo} rm -f #{remote_tmp_dir}/#{filename}"
+ run "#{try_sudo} rm -f #{remote_tmp_dir}/#{sqlfile}"
end
end
end
Something went wrong with that request. Please try again.