module Cloner::RSync
Public Instance Methods
rsync(from, to, directory: true, raise_on_error: false)
click to toggle source
# 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()
click to toggle source
# File lib/cloner/rsync.rb, line 4 def rsync_compression "-zz" end
rsync_flags()
click to toggle source
# 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)
click to toggle source
# File lib/cloner/rsync.rb, line 34 def rsync_public(folder) rsync("#{remote_app_path}/public/#{folder}", Rails.root.join("public/#{folder}")) end