Class: Synco::Methods::RSyncSnapshot
Instance Attribute Summary
#arguments, #options
Attributes inherited from Controller
#events
Instance Method Summary
collapse
Methods inherited from RSync
#connect_arguments, #default_command, #escape
Methods inherited from Controller
#abort!, build, #fire, #freeze, #on, #try
Constructor Details
#initialize(*command, arguments: [], archive: true, stats: true, **options) ⇒ RSyncSnapshot
Returns a new instance of RSyncSnapshot.
98
99
100
|
# File 'lib/synco/methods/rsync.rb', line 98
def initialize(*command, arguments: [], archive: true, stats: true, **options)
super
end
|
Instance Method Details
#call(scope) ⇒ Object
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
# File 'lib/synco/methods/rsync.rb', line 122
def call(scope)
master_server = scope.master_server
target_server = scope.target_server
directory = scope.directory
incremental_path = compute_incremental_path(directory)
link_arguments = compute_link_arguments(directory, incremental_path)
target_server.run("mkdir", "-p", target_server.full_path(incremental_path))
master_server.run(
*@command,
*@arguments,
*directory.arguments,
*connect_arguments(master_server, target_server),
*link_arguments,
master_server.connection_string(directory, on: master_server),
target_server.connection_string(incremental_path, on: master_server)
)
rescue CommandFailure => failure
raise unless failure.status.to_i == 24
end
|
#compute_incremental_path(directory) ⇒ Object
110
111
112
|
# File 'lib/synco/methods/rsync.rb', line 110
def compute_incremental_path(directory)
File.join(snapshot_name, directory.path)
end
|
#compute_link_arguments(directory, incremental_path) ⇒ Object
114
115
116
117
118
119
120
|
# File 'lib/synco/methods/rsync.rb', line 114
def compute_link_arguments(directory, incremental_path)
depth = Directory.depth(incremental_path)
latest_path = File.join("../" * depth, latest_name, directory.path)
return ["--link-dest", latest_path]
end
|
#latest_name ⇒ Object
106
107
108
|
# File 'lib/synco/methods/rsync.rb', line 106
def latest_name
@options[:latest_name] || LATEST_NAME
end
|
#snapshot_name ⇒ Object
102
103
104
|
# File 'lib/synco/methods/rsync.rb', line 102
def snapshot_name
@options[:snapshot_name] || SNAPSHOT_NAME
end
|