8

Seems like Capistrano used to have an extensive file transfer package.

However, it seems to be gone in version 3.0 after the rewrite. Any idea if there is some alternative way to still transfer files to/from servers?

Giacomo1968
  • 25,759
  • 11
  • 71
  • 103
shaimo
  • 376
  • 3
  • 17
  • There is a `download!` function now https://github.com/capistrano/sshkit/blob/v0.0.34/lib/sshkit/backends/netssh.rb#L82 – sguha Nov 15 '13 at 21:03

3 Answers3

10

To download:

desc "download foobar.txt into local_dir/"
task :foobar do
  download! "some_remote_path/foobar.txt", "local_dir/"
end

I know this works as of Cap 3.2.1, as I'm using it right now.

Grant Birchmeier
  • 17,809
  • 11
  • 63
  • 98
  • Note that the remote path must be ABSOLUTE, not relative. (I.e. the same as what you'd type when doing an `scp` command directly.) For example, you can do `download! "#{release_path}/path/within/project", "local_dir/"` – Tom Lord Mar 03 '16 at 14:44
6

I asked about this on IRC and found that there is still an upload function:

on hosts do |host|
  upload! '/config/database.yml', '/opt/my_project/shared/database.yml'
end

https://github.com/leehambley/sshkit/blob/master/EXAMPLES.md However I have yet to find a way to download files from the server without using rsync or scp

3

You could use rsync

run_locally do
execute"rsync -ah --progress source destination"
end
zechtz
  • 442
  • 5
  • 10