lib/dreamback/backup.rb in dreamback-0.0.7 vs lib/dreamback/backup.rb in dreamback-0.0.8
- old
+ new
@@ -15,11 +15,11 @@
end
# Rotate out the backups that are past our limit
# @returns [String] name of the most recent folder to link against
def self.rotate_backups
- backup_to_link = ""
+ backup_to_link = nil
Net::SFTP.start(Dreamback.settings[:backup_server], Dreamback.settings[:backup_server_user]) do |sftp|
# Create the backup folder if it doesn't exist
backup_folder_exists = false
begin
sftp.stat!(BACKUP_FOLDER) do |response|
@@ -37,9 +37,10 @@
backup_folders << [ entry.name, entry.name.split(".")[1].to_i ] if entry.name.include?("dreamback")
backup_folders.sort! {|a,b| b <=> a}
end
end
+ # Don't rotate if there aren't any previous folders
unless backup_folders.empty?
# Get yesterday's folder to link against
backup_to_link = backup_folders.first[0]
# If this would link us to the same folder, don't do that. Try yesterday's instead.
if backup_to_link.eql? "dreamback." + Date.today.strftime("%Y%m%d")
\ No newline at end of file