Class: EY::Backup::Database
- Inherits:
-
Object
- Object
- EY::Backup::Database
- Defined in:
- lib/ey_backup/database.rb
Instance Attribute Summary collapse
-
#base_path ⇒ Object
readonly
Returns the value of attribute base_path.
-
#engine ⇒ Object
readonly
Returns the value of attribute engine.
-
#environment ⇒ Object
readonly
Returns the value of attribute environment.
-
#keep ⇒ Object
readonly
Returns the value of attribute keep.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #backups ⇒ Object
- #bucket_minder ⇒ Object
- #dump ⇒ Object
- #generate_basename ⇒ Object
-
#initialize(engine, base_path, keep, backend, environment, name) ⇒ Database
constructor
A new instance of Database.
- #start_upload(filenames) ⇒ Object
- #timestamp ⇒ Object
Constructor Details
#initialize(engine, base_path, keep, backend, environment, name) ⇒ Database
Returns a new instance of Database.
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/ey_backup/database.rb', line 4 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 |
Instance Attribute Details
#base_path ⇒ Object (readonly)
Returns the value of attribute base_path.
15 16 17 |
# File 'lib/ey_backup/database.rb', line 15 def base_path @base_path end |
#engine ⇒ Object (readonly)
Returns the value of attribute engine.
15 16 17 |
# File 'lib/ey_backup/database.rb', line 15 def engine @engine end |
#environment ⇒ Object (readonly)
Returns the value of attribute environment.
15 16 17 |
# File 'lib/ey_backup/database.rb', line 15 def environment @environment end |
#keep ⇒ Object (readonly)
Returns the value of attribute keep.
15 16 17 |
# File 'lib/ey_backup/database.rb', line 15 def keep @keep end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
15 16 17 |
# File 'lib/ey_backup/database.rb', line 15 def name @name end |
Instance Method Details
#backups ⇒ Object
21 22 23 24 |
# File 'lib/ey_backup/database.rb', line 21 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 |
#bucket_minder ⇒ Object
17 18 19 |
# File 'lib/ey_backup/database.rb', line 17 def bucket_minder @backend.bucket_minder end |
#dump ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/ey_backup/database.rb', line 26 def dump FileUtils.mkdir_p(@base_path) basename = generate_basename file = @engine.dump(@name, basename) BackupSet.from(self, basename, file) end |
#generate_basename ⇒ Object
39 40 41 |
# File 'lib/ey_backup/database.rb', line 39 def generate_basename "#{@base_path}/#{@name}.#{}" end |
#start_upload(filenames) ⇒ Object
35 36 37 |
# File 'lib/ey_backup/database.rb', line 35 def start_upload(filenames) @backend.start_upload(filenames, @environment, @name) end |
#timestamp ⇒ Object
43 44 45 |
# File 'lib/ey_backup/database.rb', line 43 def Time.now.strftime("%Y-%m-%dT%H-%M-%S") end |