class ServerBackups::RestoreBase

Constants

TIMESTAMP_REGEXP

Attributes

config[R]
database[R]
restore_point[R]
s3[R]
working_dir[R]

Public Class Methods

new(config_file, working_dir, restore_point) click to toggle source
# File lib/server_backups/restore_base.rb, line 7
def initialize(config_file, working_dir, restore_point)
    @working_dir = working_dir
    @config = Config.new(config_file)
    Time.zone = config.time_zone
    @restore_point = if restore_point.present?
                         restore_point
                     else
                         Time.zone.now
                     end
    @s3 = S3.new(config)
    logger.debug "Initialized #{title}."
end

Private Instance Methods

all_files() click to toggle source
# File lib/server_backups/restore_base.rb, line 35
def all_files
    @all_files ||= s3.get_ordered_collection(s3_prefix)
end
extract_backup_time_from_filename(filename) click to toggle source
# File lib/server_backups/restore_base.rb, line 27
def extract_backup_time_from_filename(filename)
    time_parts = TIMESTAMP_REGEXP.match(filename).captures
    # Add in hours and seconds arguments
    # https://ruby-doc.org/core-2.2.0/Time.html#method-c-new
    time_parts.insert(4, 0, 0)
    Time.new(*time_parts)
end
last_command_succeeded?() click to toggle source
# File lib/server_backups/restore_base.rb, line 43
def last_command_succeeded?
    $CHILD_STATUS.exitstatus.zero?
end
logger() click to toggle source
# File lib/server_backups/restore_base.rb, line 39
def logger
    config.logger
end
title() click to toggle source
# File lib/server_backups/restore_base.rb, line 22
def title
    self.class.name.demodulize.titleize
end