Class: Backup::Api
- Inherits:
-
Object
- Object
- Backup::Api
- Defined in:
- lib/capistrano/ops/rails/lib/backup/api.rb
Instance Attribute Summary collapse
-
#backup_provider ⇒ Object
Returns the value of attribute backup_provider.
-
#provider_config ⇒ Object
Returns the value of attribute provider_config.
Instance Method Summary collapse
-
#initialize(provider: ENV['BACKUP_PROVIDER'], provider_config: {}) ⇒ Api
constructor
A new instance of Api.
- #remove_old_backups(basename, keep) ⇒ Object
- #upload(backup_file, filename, type = 'file') ⇒ Object
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_provider ⇒ Object
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_config ⇒ Object
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, type = 'file') ⇒ 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, type = 'file') case backup_provider when 's3' s3 = Backup::S3.new(**provider_config) s3.upload_stream(backup_file, filename, type) 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 |