56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
# File 'lib/synco/command/rotate.rb', line 56
def invoke(parent)
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
|