class Synco::Command::Rotate
Public Instance Methods
backup_name()
click to toggle source
# File lib/synco/command/rotate.rb, line 52 def backup_name backup_timestamp.strftime(@options[:format]) end
backup_timestamp()
click to toggle source
# File lib/synco/command/rotate.rb, line 42 def backup_timestamp timestamp = Time.now.utc #if timezone = @options[:timezone] # timestamp = timestamp.in_time_zone(timezone) #end return timestamp end
call()
click to toggle source
# File lib/synco/command/rotate.rb, line 56 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}" # Move rotated dir FileUtils.mv(snapshot_name, rotated_name) # Recreate latest symlink 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