Class: Backup::Api

Inherits:
Object
  • Object
show all
Defined in:
lib/capistrano/ops/rails/lib/backup/api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(provider: ENV['BACKUP_PROVIDER'], provider_config: {}) ⇒ Api

Returns a new instance of Api.



7
8
9
10
# File 'lib/capistrano/ops/rails/lib/backup/api.rb', line 7

def initialize(provider: ENV['BACKUP_PROVIDER'], provider_config: {})
  self.backup_provider = provider
  self.provider_config = provider_config
end

Instance Attribute Details

#backup_providerObject

Returns the value of attribute backup_provider.



5
6
7
# File 'lib/capistrano/ops/rails/lib/backup/api.rb', line 5

def backup_provider
  @backup_provider
end

#provider_configObject

Returns the value of attribute provider_config.



5
6
7
# File 'lib/capistrano/ops/rails/lib/backup/api.rb', line 5

def provider_config
  @provider_config
end

Instance Method Details

#remove_old_backups(basename, keep) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/capistrano/ops/rails/lib/backup/api.rb', line 26

def remove_old_backups(basename, keep)
  case backup_provider
  when 's3'
    s3 = Backup::S3.new(**provider_config)
    s3.remove_old_backups(basename, keep: keep)
  when 'scp'
    p 'SCP backup not implemented yet'
  when 'rsync'
    p 'Rsync backup not implemented yet'
  else
    raise Backup::Error, 'Backup provider not configured'
  end
end

#upload(backup_file, filename) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/capistrano/ops/rails/lib/backup/api.rb', line 12

def upload(backup_file, filename)
  case backup_provider
  when 's3'
    s3 = Backup::S3.new(**provider_config)
    s3.upload(backup_file, filename)
  when 'scp'
    p 'SCP backup not implemented yet'
  when 'rsync'
    p 'Rsync backup not implemented yet'
  else
    raise Backup::Error, 'Backup provider not configured'
  end
end