Sha256: 8fbe6ad0b301c3852f2f645efefb691e5b1b383cc9bd950971eebbbe63486680

Contents?: true

Size: 1.52 KB

Versions: 2

Compression:

Stored size: 1.52 KB

Contents

module EY
  module Backup
    class Engine < Base
      include Spawner

      attr_reader :username, :password, :host, :key_id, :force, :allow_concurrent, :skip_analyze, :log_coordinates

      def self.label
        @label
      end

      def self.register(label)
        @label = label
      end

      def self.descendants
        @descendants ||= []
      end

      def self.inherited(descendant)
        descendants << descendant
      end

      def self.lookup(label)
        descendants.detect {|d| d.label == label } ||
          EY::Backup.logger.fatal("Unknown database engine: #{label}")
      end

      def initialize(username, password, host, key_id, force, allow_concurrent, skip_analyze, log_coordinates)
        @username, @password, @host, @key_id, @force, @allow_concurrent, @skip_analyze, @log_coordinates = username, password, host, key_id, force, allow_concurrent, skip_analyze, log_coordinates
      end
      
      def block_concurrent(db = nil)
        if backup_running?
          message = "Unable to backup #{db}: already a backup in progress. Use --allow_concurrent to enable concurrent backup runs."
          error(message, db) unless File.exists?('/etc/engineyard/skip_concurrent_alerts')  # this skips the dashboard alert
          abort message
        end
      end
      
      def backup_running?
        verbose %x{ps aux | grep [e]ybackup | grep rubygems}
        %x{ps -ef | grep [e]ybackup | grep rubygems | wc -l}.to_i > 1
      end

      def gpg?
        !key_id.nil? && key_id != ""
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ey_cloud_server-1.5.0 lib/ey_backup/engine.rb
ey_cloud_server-1.4.61 lib/ey_backup/engine.rb