Sha256: 962fc1b3df24d960b71a5764a5e9dcee5943bfda6afba393e2d8d4dd0481940f

Contents?: true

Size: 1.07 KB

Versions: 4

Compression:

Stored size: 1.07 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, 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

    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

4 entries across 4 versions & 1 rubygems

Version Path
capistrano-ops-1.0.8 lib/capistrano/ops/rails/lib/backup/api.rb
capistrano-ops-1.0.7 lib/capistrano/ops/rails/lib/backup/api.rb
capistrano-ops-1.0.6 lib/capistrano/ops/rails/lib/backup/api.rb
capistrano-ops-1.0.5 lib/capistrano/ops/rails/lib/backup/api.rb