class Capistrano::DBSync::Executor::Remote
Public Class Methods
new(cap, config)
click to toggle source
Calls superclass method
Capistrano::DBSync::Executor::Base::new
# File lib/capistrano/db_sync/executor/remote.rb, line 4 def initialize(cap, config) super(cap, config, :remote) load_db_config! cap.capture("cat #{File.join cap.current_path, 'config', 'database.yml'}") end
Public Instance Methods
dump_and_download_to!(local_working_dir)
click to toggle source
Returns the dump directory location that was downloaded to local machine, which is based on local_working_dir
.
# File lib/capistrano/db_sync/executor/remote.rb, line 11 def dump_and_download_to!(local_working_dir) dump! download_to!(local_working_dir) ensure clean_dump_if_needed! end
Private Instance Methods
clean_dump_if_needed!()
click to toggle source
# File lib/capistrano/db_sync/executor/remote.rb, line 36 def clean_dump_if_needed! if cleanup? cap.execute "rm -rf #{dump_dir}" cap.info "Removed #{dump_dir} from the server." else cap.info "Leaving #{dump_dir} on the server. Use \"remote: { cleanup: true}\" to remove." end end
download_to!(local_working_dir)
click to toggle source
# File lib/capistrano/db_sync/executor/remote.rb, line 28 def download_to!(local_working_dir) system "mkdir -p #{local_working_dir}" cap.download! dump_dir, local_working_dir, recursive: true cap.info "Completed database dump and download." File.join(local_working_dir, File.basename(dump_dir)) end
dump!()
click to toggle source
# File lib/capistrano/db_sync/executor/remote.rb, line 20 def dump! cap.execute "mkdir -p #{dump_dir}" exporter.dump(data_selection: config[:data_selection]).each do |cmd| cap.execute cmd end end
dump_dir()
click to toggle source
# File lib/capistrano/db_sync/executor/remote.rb, line 51 def dump_dir File.join(working_dir, "dump_#{session_id}_#{db_config['database']}") end
exporter()
click to toggle source
# File lib/capistrano/db_sync/executor/remote.rb, line 47 def exporter Postgres::Exporter.new(dump_dir, db_config) end