41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/synco/command/rotate.rb', line 41
def call
snapshot_name = @options[:snapshot]
unless File.exist? snapshot_name
$stderr.puts "Snapshot directory #{snapshot_name} does not exist!"
exit(10)
end
rotated_name = backup_name
if File.exist? rotated_name
$stderr.puts "Destination rotation name #{rotated_name} already exists!"
exit(20)
end
puts "Rotating #{snapshot_name} to #{rotated_name} in #{Dir.pwd}"
FileUtils.mv(snapshot_name, rotated_name)
latest_link = @options[:latest]
if File.symlink?(latest_link)
puts "Removing old latest link..."
FileUtils.rm(latest_link)
end
puts "Creating latest symlink to #{rotated_name}"
FileUtils.ln_s(rotated_name, latest_link)
end
|