28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/backsum/server.rb', line 28
def execute_rsync(backup_path, linkdest_path, connect, source, options)
arguments = [ "--archive", "--delete" ]
target_path = File.join(backup_path, self.host)
arguments << "--verbose" if Backsum.verbose
if linkdest_path
linkdest_abosulte_path = File.absolute_path(linkdest_path) linkdest_dir = File.join([linkdest_abosulte_path, self.host, options[:as], "/"].compact)
arguments << "--link-dest=#{linkdest_dir}" if File.exists?(linkdest_dir)
end
if options[:as]
target_path = File.join(target_path, options[:as])
else
arguments << "--relative"
end
FileUtils.mkdir_p target_path
(options[:excluded] || []).each do |pattern|
arguments << "--exclude=#{pattern}"
end
source = File.join(source, "/") if File.directory?(source)
if connect
arguments << "#{connect}:#{source}"
else
arguments << source
end
arguments << target_path
copy_command = Shell.new("rsync", arguments.map {|arg| shell_param_escape(arg) }.join(' '))
copy_command.run
end
|