Sha256: ea2c41eb342ea587bbb4bbc958785c2058e67f938eab26c01936133b71930b3d

Contents?: true

Size: 1 KB

Versions: 2

Compression:

Stored size: 1 KB

Contents

module EY
  module Backup
    class Dumper < Base
      attr_accessor :database

      def_delegators EY::Backup, :engine, :minder, :base_path

      def self.run(options = {})
        if database = options[:db]
          new(database, options).run
        else
          options[:databases].each do |database|
            new(database, options).run
          end
        end
      end

      def initialize(database, options = {})
        super(options)
        @database = database
      end

      def run
        info "doing database: #{database}"

        FileUtils.mkdir_p('/mnt/tmp')

        backup = engine.dump(database, base_name)

        backup.upload!(database)

        info "Successful backup: #{database}.#{backup.normalized_name}"
        BackupSet.cleanup(database, EY::Backup.config.keep)
      end


      def base_name
        "#{base_path}/#{database}.#{timestamp}"
      end

      def timestamp
        @timestamp ||= Time.now.strftime("%Y-%m-%dT%H:%M:%S").gsub(/:/, '-')
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ey_cloud_server-1.4.5 lib/ey_backup/dumper.rb
ey_cloud_server-1.4.5.pre lib/ey_backup/dumper.rb