Class: Wordmove::Deployer::SSH

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

Instance Attribute Summary

Attributes inherited from Base

#logger, #options

Instance Method Summary collapse

Methods inherited from Base

deployer_for, fetch_movefile, #remote_get_directory, #remote_put_directory

Constructor Details

#initialize(options) ⇒ SSH

Returns a new instance of SSH.



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

def initialize(options)
  super
  ssh_options = options[:remote][:ssh]
  @copier = Photocopier::SSH.new(ssh_options)
  @copier.logger = logger
end

Instance Method Details

#pull_dbObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/wordmove/deployer/ssh.rb', line 34

def pull_db
  super

  local_dump_path = local_wpcontent_path("dump.sql")
  remote_dump_path = remote_wpcontent_path("dump.sql")

  # dump remote db into file
  remote_run mysql_dump_command(options[:remote][:database], remote_dump_path)
  # download remote dump
  remote_get(remote_dump_path, local_dump_path)
  # gsub sql
  adapt_sql(local_dump_path, options[:remote], options[:local])
  # import locally
  run mysql_import_command(local_dump_path, options[:local][:database])
  # remove it remotely
  remote_delete(remote_dump_path)
  # and locally
  run "rm #{local_dump_path}"
end

#push_dbObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/wordmove/deployer/ssh.rb', line 14

def push_db
  super

  local_dump_path = local_wpcontent_path("dump.sql")
  remote_dump_path = remote_wpcontent_path("dump.sql")

  # dump local mysql into file
  run mysql_dump_command(options[:local][:database], local_dump_path)
  # gsub sql
  adapt_sql(local_dump_path, options[:local], options[:remote])
  # upload it
  remote_put(local_dump_path, remote_dump_path)
  # import it remotely
  remote_run mysql_import_command(remote_dump_path, options[:remote][:database])
  # remove it remotely
  remote_delete(remote_dump_path)
  # and locally
  run "rm #{local_dump_path}"
end