s3

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2025 License: BSD-2-Clause Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

func Create(ctx context.Context, cfg Config, rt http.RoundTripper) (backend.Backend, error)

Create opens the S3 backend at bucket and region and creates the bucket if it does not exist yet.

func NewFactory

func NewFactory() location.Factory

func Open

Open opens the S3 backend at bucket and region. The bucket is created if it does not exist yet.

Types

type Backend

type Backend struct {
	layout.Layout
	// contains filtered or unexported fields
}

Backend stores data on an S3 endpoint.

func (*Backend) Close

func (be *Backend) Close() error

Close does nothing

func (*Backend) Delete

func (be *Backend) Delete(ctx context.Context) error

Delete removes all restic keys in the bucket. It will not remove the bucket itself.

func (*Backend) Hasher

func (be *Backend) Hasher() hash.Hash

Hasher may return a hash function for calculating a content hash for the backend

func (*Backend) IsNotExist

func (be *Backend) IsNotExist(err error) bool

IsNotExist returns true if the error is caused by a not existing file.

func (*Backend) IsPermanentError added in v0.17.0

func (be *Backend) IsPermanentError(err error) bool

func (*Backend) List

func (be *Backend) List(ctx context.Context, t backend.FileType, fn func(backend.FileInfo) error) error

List runs fn for each file in the backend which has the type t. When an error occurs (or fn returns an error), List stops and returns it.

func (*Backend) Load

func (be *Backend) Load(ctx context.Context, h backend.Handle, length int, offset int64, fn func(rd io.Reader) error) error

Load runs fn with a reader that yields the contents of the file at h at the given offset.

func (*Backend) Path

func (be *Backend) Path() string

Path returns the path in the bucket that is used for this backend.

func (*Backend) Properties added in v0.18.0

func (be *Backend) Properties() backend.Properties

func (*Backend) Remove

func (be *Backend) Remove(ctx context.Context, h backend.Handle) error

Remove removes the blob with the given name and type.

func (*Backend) Save

Save stores data in the backend at the handle.

func (*Backend) Stat

func (be *Backend) Stat(ctx context.Context, h backend.Handle) (bi backend.FileInfo, err error)

Stat returns information about a blob.

func (*Backend) Warmup added in v0.18.0

func (be *Backend) Warmup(ctx context.Context, handles []backend.Handle) ([]backend.Handle, error)

Warmup transitions handles from cold to hot storage if needed.

func (*Backend) WarmupWait added in v0.18.0

func (be *Backend) WarmupWait(ctx context.Context, handles []backend.Handle) error

WarmupWait waits until all handles are in hot storage.

type Config

type Config struct {
	Endpoint     string
	UseHTTP      bool
	KeyID        string
	Secret       options.SecretString
	Bucket       string
	Prefix       string
	Layout       string `option:"layout" help:"use this backend layout (default: auto-detect) (deprecated)"`
	StorageClass string `` /* 129-byte string literal not displayed */

	EnableRestore  bool          `` /* 146-byte string literal not displayed */
	RestoreDays    int           `option:"restore-days" help:"lifetime in days of restored object (default: 7)"`
	RestoreTimeout time.Duration `option:"restore-timeout" help:"maximum time to wait for objects transition (default: 1d)"`
	RestoreTier    string        `` /* 133-byte string literal not displayed */

	Connections         uint   `option:"connections" help:"set a limit for the number of concurrent connections (default: 5)"`
	MaxRetries          uint   `option:"retries" help:"set the number of retries attempted"`
	Region              string `option:"region" help:"set region"`
	BucketLookup        string `option:"bucket-lookup" help:"bucket lookup style: 'auto', 'dns', or 'path'"`
	ListObjectsV1       bool   `option:"list-objects-v1" help:"use deprecated V1 api for ListObjects calls"`
	UnsafeAnonymousAuth bool   `option:"unsafe-anonymous-auth" help:"use anonymous authentication"`
}

Config contains all configuration necessary to connect to an s3 compatible server.

func NewConfig

func NewConfig() Config

NewConfig returns a new Config with the default values filled in.

func ParseConfig

func ParseConfig(s string) (*Config, error)

ParseConfig parses the string s and extracts the s3 config. The two supported configuration formats are s3://host/bucketname/prefix and s3:host/bucketname/prefix. The host can also be a valid s3 region name. If no prefix is given the prefix "restic" will be used.

func (*Config) ApplyEnvironment

func (cfg *Config) ApplyEnvironment(prefix string)

ApplyEnvironment saves values from the environment to the config.

Jump to

Keyboard shortcuts

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