code: def find_schedule
        minutes = {
          # If a cron job is run hourly it can be off by a couple of seconds
          # from the last run. Set hourly to 58 minutes
          hourly: 58, 
          daily: 24*60,
          weekly: 7*24*60,
          monthly: 30*24*60,
          yearly: 365*24*60
        }
  
        now = DateTime.now
        [:yearly, :monthly, :weekly, :daily, :hourly].each do |schedule|
          next if backups_to_keep(schedule) <= 0
          list = list_backup_dir schedule
          date = list.map { |path| parse_backup_dir_name path, now.offset }.max
          return schedule if !date || (now - date) * 24 * 60 >= minutes[schedule]
        end
  
        nil
      end
docs: Find out which schedule to run