Module: Cloner::RSync
Instance Method Summary collapse
- #rsync(from, to, directory: true, raise_on_error: false) ⇒ Object
- #rsync_compression ⇒ Object
- #rsync_flags ⇒ Object
- #rsync_public(folder) ⇒ Object
Instance Method Details
#rsync(from, to, directory: true, raise_on_error: false) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/cloner/rsync.rb', line 13 def rsync(from, to, directory: true, raise_on_error: false) if directory from = "#{from}/" unless from.to_s.end_with?('/') to = "#{to}/" unless to.to_s.end_with?('/') end cmd = "rsync #{rsync_flags} #{e ssh_user}@#{e ssh_host}:#{e from} #{e to}" puts "Running RSync: #{cmd}" pipe = IO.popen(cmd) while (line = pipe.gets) print line if verbose? end pipe.close ret = $?.to_i if ret != 0 if raise_on_error raise "Error: local command exited with #{ret}" end puts "Error: local command exited with #{ret}" end end |
#rsync_compression ⇒ Object
4 5 6 |
# File 'lib/cloner/rsync.rb', line 4 def rsync_compression "-zz" end |
#rsync_flags ⇒ Object
8 9 10 11 |
# File 'lib/cloner/rsync.rb', line 8 def rsync_flags port = ssh_opts[:port] || 22 "#{rsync_compression} -utvr --checksum -e \"ssh -p #{port}\"" end |
#rsync_public(folder) ⇒ Object
34 35 36 |
# File 'lib/cloner/rsync.rb', line 34 def rsync_public(folder) rsync("#{remote_app_path}/public/#{folder}", Rails.root.join("public/#{folder}")) end |