Class: Wordmove::Deployer::SSH

Inherits:
Base
  • Object
show all
Defined in:
lib/wordmove/deployer/ssh.rb

Instance Attribute Summary

Attributes inherited from Base

#environment, #logger, #options

Instance Method Summary collapse

Methods inherited from Base

current_dir, deployer_for, #exclude_dir_contents, extract_available_envs, fetch_movefile, last_dir?, logger, #pull_wordpress, #push_wordpress, #remote_get_directory, #remote_put_directory, upper_dir

Constructor Details

#initialize(environment, options) ⇒ SSH

Returns a new instance of SSH.



7
8
9
10
11
# File 'lib/wordmove/deployer/ssh.rb', line 7

def initialize(environment, options)
  super
  ssh_options = remote_options[:ssh]
  @copier = Photocopier::SSH.new(ssh_options).tap { |c| c.logger = logger }
end

Instance Method Details

#pull_dbObject



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/wordmove/deployer/ssh.rb', line 26

def pull_db
  super

  local_dump_path = local_wp_content_dir.path("dump.sql")
  remote_dump_path = remote_wp_content_dir.path("dump.sql")
  local_backup_path = local_wp_content_dir.path("local-backup-#{Time.now.to_i}.sql")
  save_local_db(local_backup_path)

  download_remote_db(local_dump_path)
  adapt_sql(local_dump_path, remote_options, local_options)
  run mysql_import_command(local_dump_path, local_options[:database])
  run "rm #{local_dump_path}"
end

#push_dbObject



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/wordmove/deployer/ssh.rb', line 13

def push_db
  super

  local_dump_path = local_wp_content_dir.path("dump.sql")
  local_backup_path = local_wp_content_dir.path("#{environment}-backup-#{Time.now.to_i}.sql")
  download_remote_db(local_backup_path)

  save_local_db(local_dump_path)
  adapt_sql(local_dump_path, local_options, remote_options)
  import_remote_dump(local_dump_path)
  run "rm #{local_dump_path}"
end