cloud

package
v2.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 19, 2017 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package cloud manages the backup in a specific cloud.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MultipartUploadLimit

func MultipartUploadLimit(value int64)

MultipartUploadLimit defines the limit where we decide if we will send the file in one shot or if we will use multipart upload strategy. By default we use 100 MB.

func PartSize

func PartSize(value int64)

PartSize the size of each part of the multipart upload except the last, in bytes. The last part can be smaller than this part size. By default we use 4MB.

func WaitJobTime

func WaitJobTime(value time.Duration)

WaitJobTime is the amount of time that we wait for the job to complete, as it takes some time, we will sleep for a long time before we check again. By default we use 1 minute.

Types

type AWSCloud

type AWSCloud struct {
	AccountID string
	VaultName string
	Glacier   glacieriface.GlacierAPI
	Clock     Clock
}

AWSCloud is the Amazon solution for storing the backups in the cloud. It uses the Amazon Glacier service, as it allows large files for a small price.

func NewAWSCloud

func NewAWSCloud(c *config.Config, debug bool) (*AWSCloud, error)

NewAWSCloud initializes the Amazon cloud object, defining the account ID and vault name that are going to be used in the AWS Glacier service. For more details set the debug flag to receive low level information in the standard output.

func (*AWSCloud) Get

func (a *AWSCloud) Get(id string) (string, error)

Get retrieves a specific backup file and stores it locally in a file. The filename storing the location of the file is returned.

func (*AWSCloud) List

func (a *AWSCloud) List() ([]Backup, error)

List retrieves all the uploaded backups information in the cloud.

func (*AWSCloud) Remove

func (a *AWSCloud) Remove(id string) error

Remove erase a specific backup from the cloud.

func (*AWSCloud) Send

func (a *AWSCloud) Send(filename string) (Backup, error)

Send uploads the file to the cloud and return the backup archive information. It already has the logic to send directly if it's a small file or use multipart strategy if it's a large file.

type AWSIventoryArchiveList

type AWSIventoryArchiveList []struct {
	ArchiveID          string    `json:"ArchiveId"`
	ArchiveDescription string    `json:"ArchiveDescription"`
	CreationDate       time.Time `json:"CreationDate"`
	Size               int       `json:"Size"`
	SHA256TreeHash     string    `json:"SHA256TreeHash"`
}

AWSIventoryArchiveList stores the archive information retrieved from AWS Glacier service.

func (AWSIventoryArchiveList) Len

func (a AWSIventoryArchiveList) Len() int

func (AWSIventoryArchiveList) Less

func (a AWSIventoryArchiveList) Less(i, j int) bool

func (AWSIventoryArchiveList) Swap

func (a AWSIventoryArchiveList) Swap(i, j int)

type Backup

type Backup struct {
	// ID primary key to identify the archive in the cloud.
	ID string

	// Time that the archive was created in the cloud.
	CreatedAt time.Time

	// Checksum is a SHA256 of the archive content.
	Checksum string

	// VaultName is the identifier of the place in the cloud where the archive was
	// stored.
	VaultName string
}

Backup store all the necessary information of an already uploaded archive.

type Clock

type Clock interface {
	// Now returns the current date and time.
	Now() time.Time
}

Clock used to retrieve the current time. Useful for mocking in test environments, or if you want you own implementation of clock to be used.

type Cloud

type Cloud interface {
	// Send uploads the file to the cloud and return the backup archive
	// information.
	Send(filename string) (Backup, error)

	// List retrieves all the uploaded backups information in the cloud.
	List() ([]Backup, error)

	// Get retrieves a specific backup file and stores it locally in a file. The
	// filename storing the location of the file is returned.
	Get(id string) (filename string, err error)

	// Remove erase a specific backup from the cloud.
	Remove(id string) error
}

Cloud offers all necessary operations to manage backups in the cloud.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL