Sha256: 1041692f52baa81d7f99160b8d6e71790df9693f7179974b4d52147c07ef9344

Contents?: true

Size: 1.2 KB

Versions: 16

Compression:

Stored size: 1.2 KB

Contents

module EY
  module Backup
    class Database
      def initialize(engine, base_path, keep, backend, environment, name)
        if name.nil? || name.empty?
          raise ArgumentError, "database name is blank"
        end
        @engine    = engine
        @base_path = base_path
        @keep      = keep
        @backend = backend
        @environment = environment
        @name = name
      end
      attr_reader :name, :engine, :environment, :keep, :base_path

      def bucket_minder
        @backend.bucket_minder
      end

      def backups
        s3_objects = bucket_minder.list("#{@environment}.#{@name}").select { |o| o[:name] =~ @engine.suffix }
        s3_objects.map {|o| BackupSet.new(self, o[:name], nil, o[:keys]) }.sort
      end

      def dump
        FileUtils.mkdir_p(@base_path)

        basename = generate_basename
        file = @engine.dump(@name, basename)

        BackupSet.from(self, basename, file)
      end

      def start_upload(filenames)
        @backend.start_upload(filenames, @environment, @name)
      end

      def generate_basename
        "#{@base_path}/#{@name}.#{timestamp}"
      end

      def timestamp
        Time.now.strftime("%Y-%m-%dT%H-%M-%S")
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
ey_cloud_server-1.4.44 lib/ey_backup/database.rb
ey_cloud_server-1.4.43 lib/ey_backup/database.rb
ey_cloud_server-1.4.41 lib/ey_backup/database.rb
ey_cloud_server-1.4.40 lib/ey_backup/database.rb
ey_cloud_server-1.4.39 lib/ey_backup/database.rb
ey_cloud_server-1.4.37 lib/ey_backup/database.rb
ey_cloud_server-1.4.37.ruby19 lib/ey_backup/database.rb
ey_cloud_server-1.4.36 lib/ey_backup/database.rb
ey_cloud_server-1.4.34 lib/ey_backup/database.rb
ey_cloud_server-1.4.33 lib/ey_backup/database.rb
ey_cloud_server-1.4.32 lib/ey_backup/database.rb
ey_cloud_server-1.4.31 lib/ey_backup/database.rb
ey_cloud_server-1.4.29 lib/ey_backup/database.rb
ey_cloud_server-1.4.28 lib/ey_backup/database.rb
ey_cloud_server-1.4.28.pre lib/ey_backup/database.rb
ey_cloud_server-1.4.26 lib/ey_backup/database.rb