Sha256: 6da10ab9fffde9556f453bf87bdd301a0b4023043870f3ea82e238df8d0e8e0a

Contents?: true

Size: 1.05 KB

Versions: 16

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

module Backup
  class Api
    attr_accessor :backup_provider, :provider_config

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

    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

    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
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
capistrano-ops-1.0.4 lib/capistrano/ops/rails/lib/backup/api.rb
capistrano-ops-1.0.3 lib/capistrano/ops/rails/lib/backup/api.rb
capistrano-ops-1.0.2 lib/capistrano/ops/rails/lib/backup/api.rb
capistrano-ops-1.0.1 lib/capistrano/ops/rails/lib/backup/api.rb
capistrano-ops-1.0.0 lib/capistrano/ops/rails/lib/backup/api.rb
capistrano-ops-0.2.14 lib/capistrano/ops/backup/api.rb
capistrano-ops-0.2.13 lib/capistrano/ops/backup/api.rb
capistrano-ops-0.2.12 lib/capistrano/ops/backup/api.rb
capistrano-ops-0.2.11 lib/capistrano/ops/backup/api.rb
capistrano-ops-0.2.10 lib/capistrano/ops/backup/api.rb
capistrano-ops-0.2.9 lib/capistrano/ops/backup/api.rb
capistrano-ops-0.2.8 lib/capistrano/ops/backup/api.rb
capistrano-ops-0.2.7 lib/capistrano/ops/backup/api.rb
capistrano-ops-0.2.6 lib/capistrano/ops/backup/api.rb
capistrano-ops-0.2.5 lib/capistrano/ops/backup/api.rb
capistrano-ops-0.2.4 lib/capistrano/ops/backup/api.rb