backup

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package backup implements encrypted addon backups to S3-compatible storage and the minimal AWS Signature V4 client they need. The client is stdlib-only (golden rule 7): no SDK.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("s3: object not found")

ErrNotFound is returned by Get for a missing key.

Functions

func SizeString

func SizeString(n int64) string

SizeString formats a byte count for logs.

Types

type Object

type Object struct {
	Key          string
	Size         int64
	LastModified string
}

Object is one listed key.

type S3

type S3 struct {
	// Endpoint is the service URL, e.g. https://s3.eu-central-1.amazonaws.com or
	// http://minio:9000 (MinIO, path-style).
	Endpoint  string
	Region    string
	Bucket    string
	AccessKey string
	SecretKey string
	// PathStyle addresses objects as <endpoint>/<bucket>/<key> (MinIO); otherwise the bucket
	// becomes a host prefix.
	PathStyle bool
	HTTP      *http.Client
	// Now is overridable for tests (signing uses it).
	Now func() time.Time
}

S3 is a minimal SigV4 client for PUT/GET/DELETE/LIST on one bucket.

func (*S3) Delete

func (s *S3) Delete(ctx context.Context, key string) error

Delete removes key (missing keys are not an error on S3).

func (*S3) Get

func (s *S3) Get(ctx context.Context, key string) (io.ReadCloser, error)

Get downloads key.

func (*S3) List

func (s *S3) List(ctx context.Context, prefix string) ([]Object, error)

List returns objects under prefix (ListObjectsV2, paginated).

func (*S3) Put

func (s *S3) Put(ctx context.Context, key string, body io.Reader, size int64) error

Put uploads body (size bytes) to key. The payload hash is computed by streaming through a hasher when size is small enough to buffer; otherwise UNSIGNED-PAYLOAD is used (TLS protects integrity in transit; the object itself is age-encrypted and authenticated).

func (*S3) Validate

func (s *S3) Validate() error

Validate checks the configuration.

Jump to

Keyboard shortcuts

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