-
-
Save bf4/7e02f97b60c9e0bd09ce0f2ae8bdb662 to your computer and use it in GitHub Desktop.
Revisions
-
bf4 revised this gist
Jun 19, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,7 +5,7 @@ def database_dump pipe = IO.popen("pg_dump '#{database}' -F c") stream = response.stream while (line = pipe.read(1024)) # per https://gist.github.com/njakobsen/6257887#gistcomment-1238467 stream.write line Thread.pass # per https://gist.github.com/njakobsen/6257887#gistcomment-1235792 end -
bf4 revised this gist
Jun 19, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,7 +7,7 @@ def database_dump stream = response.stream while (line = pipe.gets) stream.write line Thread.pass # per https://gist.github.com/njakobsen/6257887#gistcomment-1235792 end rescue IOError # Client Disconnected -
njakobsen revised this gist
Aug 29, 2013 . 1 changed file with 1 addition and 9 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -19,15 +19,7 @@ def database_dump # Code that allows us to only mix in the live methods if we're accessing the desired action def dispatch(name, *args) extend ActionController::Live if name.to_s == 'database_dump' super end end -
njakobsen revised this gist
Aug 29, 2013 . 1 changed file with 17 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,5 @@ class DatabaseController < ApplicationController def database_dump database = Rails.configuration.database_configuration[Rails.env]["database"] send_file_headers!(:type => 'application/octet-stream', :filename => "#{database}_#{Time.now.to_s(:human)}.backup") @@ -13,4 +14,20 @@ class DatabaseController < ApplicationController ensure pipe.close response.stream.close end # Code that allows us to only mix in the live methods if we're accessing the desired action def dispatch(name, *args) extend ActionController::Live if Array(@@live_actions).include?(name.to_s) super end @@live_actions = [] def self.live(actions) @@live_actions |= Array(actions).collect(&:to_s) end live :database_dump end -
njakobsen revised this gist
Aug 21, 2013 . 1 changed file with 7 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,13 +1,16 @@ class DatabaseController < ApplicationController database = Rails.configuration.database_configuration[Rails.env]["database"] send_file_headers!(:type => 'application/octet-stream', :filename => "#{database}_#{Time.now.to_s(:human)}.backup") pipe = IO.popen("pg_dump '#{database}' -F c") stream = response.stream while (line = pipe.gets) stream.write line sleep 0.0001 # HACK: Prevent server instance from sleeping forever if client disconnects during download end rescue IOError # Client Disconnected ensure pipe.close response.stream.close end -
njakobsen revised this gist
Aug 17, 2013 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,4 @@ class DatabaseController < ApplicationController include ActionController::Live def database_dump database = Rails.configuration.database_configuration[Rails.env]["database"] @@ -9,3 +10,4 @@ def database_dump end response.stream.close end end -
njakobsen renamed this gist
Aug 17, 2013 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
njakobsen created this gist
Aug 17, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,11 @@ include ActionController::Live def database_dump database = Rails.configuration.database_configuration[Rails.env]["database"] send_file_headers!(:type => 'application/octet-stream', :filename => "#{database}_#{Time.now.to_s(:human)}.backup") pipe = IO.popen("pg_dump '#{database}' -F c") while (line = pipe.gets) response.stream.write line end response.stream.close end