Sha256: eefee0c0f9e10d1e808e7b1df3f4116b5bcad4c73bb4d03e0ea2352b742111c0
Contents?: true
Size: 1.65 KB
Versions: 3
Compression:
Stored size: 1.65 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 @backup_size = nil end attr_reader :name, :engine, :environment, :keep, :base_path, :backup_size 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) @backup_size = number_to_human_size(File.size(file)) 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 def number_to_human_size(size) if size < 1024 "#{size} bytes" elsif size < 1024.0 * 1024.0 "%.01f KB" % (size / 1024.0) elsif size < 1024.0 * 1024.0 * 1024.0 "%.01f MB" % (size / 1024.0 / 1024.0) else "%.01f GB" % (size / 1024.0 / 1024.0 / 1024.0) end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ey_cloud_server-1.4.51 | lib/ey_backup/database.rb |
ey_cloud_server-1.4.50 | lib/ey_backup/database.rb |
ey_cloud_server-1.4.49 | lib/ey_backup/database.rb |