Method: Bard::Copy#rsync_using_local

Defined in:
lib/bard/copy.rb

#rsync_using_local(direction, server) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/bard/copy.rb', line 52

def rsync_using_local direction, server
  gateway = server.gateway ? "-oProxyCommand=\"ssh #{server.ssh_uri(:gateway)} -W %h:%p\"" : ""

  ssh_key = server.ssh_key ? "-i #{server.ssh_key}" : ""
  ssh = "-e'ssh #{gateway} -p#{server.ssh_uri.port || 22}'"

  from_and_to = ["./#{path}", server.rsync_uri(path)]
  from_and_to.reverse! if direction == :from
  from_and_to[-1].sub! %r(/[^/]+$), '/'

  command = "rsync #{ssh} --delete --info=progress2 -az #{from_and_to.join(" ")}"
  Bard::Command.run! command, verbose: verbose
end