class Dumpman::Fetchers::Direct
it triggers rake db:dump inside app_path
and copies dump into tmp directory after that it gets dump from remote server
Attributes
app_env[R]
app_path[R]
ssh_cmd[R]
ssh_opts[R]
Public Class Methods
new(ssh_opts:, ssh_cmd:, app_path:, app_env:, **)
click to toggle source
# File lib/dumpman/fetchers/direct.rb, line 10 def initialize(ssh_opts:, ssh_cmd:, app_path:, app_env:, **) @ssh_opts = ssh_opts @ssh_cmd = ssh_cmd @app_path = app_path @app_env = app_env end
Public Instance Methods
get_dump()
click to toggle source
# File lib/dumpman/fetchers/direct.rb, line 17 def get_dump Dumpman::Executor.system(make_dump_remotely) do |dump_location| Dumpman::Executor.system(fetch_dump_to_local(dump_location)) end end
Private Instance Methods
fetch_dump_to_local(dump_location)
click to toggle source
# File lib/dumpman/fetchers/direct.rb, line 38 def fetch_dump_to_local(dump_location) <<~SSH_COMMAND scp #{ssh_opts} #{ssh_cmd}:#{dump_location}/#{Dumpman.dump_file_name} \ #{Dumpman.dump_folder}/ SSH_COMMAND end
make_dump_remotely()
click to toggle source
# File lib/dumpman/fetchers/direct.rb, line 25 def make_dump_remotely <<~SSH_COMMAND ssh #{ssh_opts} #{ssh_cmd} '\ export TEMP_DIR=$(mktemp -d)\ cd #{app_path} && \ bash --login -c "RAILS_ENV=#{app_env} bundle exec rake db:dump \ && cp #{Dumpman.dump_file_name} $TEMP_DIR/"\ echo $TEMP_DIR' SSH_COMMAND end