class LSync::Methods::RSync
0 Success 1 Syntax or usage error 2 Protocol incompatibility 3 Errors selecting input/output files, dirs 4 Requested action not supported: an attempt was made to manipulate 64-bit files on a platform
that cannot support them; or an option was specified that is supported by the client and not by the server.
5 Error
starting client-server protocol 6 Daemon unable to append to log-file 10 Error
in socket I/O 11 Error
in file I/O 12 Error
in rsync protocol data stream 13 Errors with program diagnostics 14 Error
in IPC code 20 Received SIGUSR1 or SIGINT 21 Some error returned by waitpid() 22 Error
allocating core memory buffers 23 Partial transfer due to error 24 Partial transfer due to vanished source files 25 The –max-delete limit stopped deletions 30 Timeout
in data send/receive 35 Timeout
waiting for daemon connection
Public Class Methods
LSync::Method::new
# File lib/lsync/methods/rsync.rb, line 51 def initialize(direction, options = {}) super(options) @direction = direction @command = options[:command] || "rsync" @options = options @connection = nil end
Public Instance Methods
# File lib/lsync/methods/rsync.rb, line 101 def run(controller) directory = controller.directory arguments = (@options[:arguments] || ["--archive"]) + (directory.options[:arguments] || []) local_server, remote_server, source, destination = configuration(controller, controller.directory, controller.directory) arguments += connect_arguments(local_server, remote_server) # Create the destination backup directory controller.target.exec!(["mkdir", "-p", controller.target.full_path(directory.path)]) run_handler(controller, local_server, source, destination, arguments) end
# File lib/lsync/methods/rsync.rb, line 115 def run_handler(controller, local_server, source, destination, arguments) command = [@command] + arguments + [source, destination] local_server.exec(command) do |task| LSync::log_task(task, controller.logger) result = task.wait # Exit status 24 means that some files were deleted between indexing the data and copying it. unless result.exitstatus == 0 || result.exitstatus == 24 raise BackupMethodError.new("Backup from #{source} to #{destination} failed.", :method => self) end end end
# File lib/lsync/methods/rsync.rb, line 130 def should_run?(controller) if @direction == :push return controller.current == controller.master elsif @direction == :pull return controller.target.local? else return false end end
Protected Instance Methods
# File lib/lsync/methods/rsync.rb, line 76 def configuration(controller, source_directory, destination_directory) local_server = nil remote_server = nil source = nil destination = nil if @direction == :push local_server = controller.master remote_server = controller.target destination = remote_server.connection_string(destination_directory) source = local_server.full_path(source_directory) else local_server = controller.target remote_server = controller.master source = remote_server.connection_string(source_directory) destination = local_server.full_path(destination_directory) end return local_server, remote_server, source, destination end
# File lib/lsync/methods/rsync.rb, line 63 def connect_arguments (local_server, remote_server) # RSync -e option simply appends the hostname. There is no way to control this behaviour. command = remote_server.shell.connection_command(remote_server) if command.last != remote_server.host abort "RSync shell requires hostname at end of command! #{cmd.inspect}" else command.pop end return ['-e', command.to_cmd] end