storage

package
v0.8.14 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Package storage provides storage backend implementations for local, S3, and SFTP.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BackupInfo

type BackupInfo struct {
	Path         string
	Size         int64
	LastModified time.Time
	StorageName  string
}

BackupInfo contains metadata about a stored backup

type Local

type Local struct {
	// contains filtered or unexported fields
}

Local implements Storage for local filesystem

func NewLocal

func NewLocal(cfg *config.Storage) *Local

NewLocal creates a new local storage backend

func (*Local) Delete

func (l *Local) Delete(_ context.Context, path string) error

Delete removes a backup from local filesystem

func (*Local) Exists

func (l *Local) Exists(_ context.Context, path string) (bool, error)

Exists checks if a backup file exists

func (*Local) GetInfo

func (l *Local) GetInfo(_ context.Context, path string) (*BackupInfo, error)

GetInfo returns metadata about a backup file

func (*Local) List

func (l *Local) List(_ context.Context) ([]*BackupInfo, error)

List returns all backup files in the storage

func (*Local) Name

func (l *Local) Name() string

Name returns the storage name

func (*Local) Retrieve

func (l *Local) Retrieve(_ context.Context, path string, w io.Writer) error

Retrieve reads data from local filesystem into writer

func (*Local) Store

func (l *Local) Store(_ context.Context, path string, r io.Reader, _ int64) error

Store writes data from reader to local filesystem

func (*Local) Validate

func (l *Local) Validate(_ context.Context) error

Validate checks if the storage path exists and is writable

type S3

type S3 struct {
	// contains filtered or unexported fields
}

S3 implements Storage for AWS S3 and S3-compatible services

func NewS3

func NewS3(cfg *bconfig.Storage) *S3

NewS3 creates a new S3 storage backend

func (*S3) Delete

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

Delete removes a backup from S3

func (*S3) Exists

func (s *S3) Exists(ctx context.Context, filePath string) (bool, error)

Exists checks if a backup file exists in S3

func (*S3) GetInfo

func (s *S3) GetInfo(ctx context.Context, filePath string) (*BackupInfo, error)

GetInfo returns metadata about a backup file in S3

func (*S3) List

func (s *S3) List(ctx context.Context) ([]*BackupInfo, error)

List returns all backup files in S3

func (*S3) Name

func (s *S3) Name() string

Name returns the storage name

func (*S3) Retrieve

func (s *S3) Retrieve(ctx context.Context, filePath string, w io.Writer) error

Retrieve reads data from S3 into writer

func (*S3) Store

func (s *S3) Store(ctx context.Context, filePath string, r io.Reader, size int64) error

Store writes data from reader to S3

func (*S3) Validate

func (s *S3) Validate(ctx context.Context) error

Validate checks if S3 is accessible

type SFTP

type SFTP struct {
	// contains filtered or unexported fields
}

SFTP implements Storage for SFTP servers

func NewSFTP

func NewSFTP(cfg *config.Storage) *SFTP

NewSFTP creates a new SFTP storage backend

func (*SFTP) Delete

func (s *SFTP) Delete(_ context.Context, filePath string) error

Delete removes a backup from SFTP

func (*SFTP) Exists

func (s *SFTP) Exists(_ context.Context, filePath string) (bool, error)

Exists checks if a backup file exists in SFTP

func (*SFTP) GetInfo

func (s *SFTP) GetInfo(_ context.Context, filePath string) (*BackupInfo, error)

GetInfo returns metadata about a backup file in SFTP

func (*SFTP) List

func (s *SFTP) List(_ context.Context) ([]*BackupInfo, error)

List returns all backup files from SFTP

func (*SFTP) Name

func (s *SFTP) Name() string

Name returns the storage name

func (*SFTP) Retrieve

func (s *SFTP) Retrieve(_ context.Context, filePath string, w io.Writer) error

Retrieve reads data from SFTP into writer

func (*SFTP) Store

func (s *SFTP) Store(ctx context.Context, filePath string, r io.Reader, _ int64) error

Store writes data from reader to SFTP

func (*SFTP) Validate

func (s *SFTP) Validate(_ context.Context) error

Validate checks if SFTP is accessible

type Storage

type Storage interface {
	// Store writes data from reader to the storage backend
	// path is relative to the storage's configured base path
	Store(ctx context.Context, path string, r io.Reader, size int64) error

	// Retrieve reads data from storage into the writer
	Retrieve(ctx context.Context, path string, w io.Writer) error

	// List returns all backup files in the storage
	List(ctx context.Context) ([]*BackupInfo, error)

	// Delete removes a backup from storage
	Delete(ctx context.Context, path string) error

	// Name returns the storage backend name
	Name() string

	// Validate checks if the storage is accessible
	Validate(ctx context.Context) error

	// Exists checks if a backup file exists
	Exists(ctx context.Context, path string) (bool, error)

	// GetInfo returns metadata about a backup file
	GetInfo(ctx context.Context, path string) (*BackupInfo, error)
}

Storage represents a backup storage backend

func New

func New(cfg *config.Storage) (Storage, error)

New creates a new storage backend based on the configuration

Jump to

Keyboard shortcuts

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