storage

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2026 License: MIT Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDownloadNotSupported = errors.New("storage does not support download")

Functions

func ApplyRetention

func ApplyRetention(ctx context.Context, storage Storage, job *config.JobConfig, storageConfig config.StorageConfig) error

func InvalidateSetCache

func InvalidateSetCache(jobName, storageName string)

func JobDirLocal

func JobDirLocal(basePath, jobName string) string

func JobDirPosix

func JobDirPosix(basePath, jobName string) string

func JobNameSegment added in v0.1.4

func JobNameSegment(includeJobName *bool, jobName string) string

JobNameSegment returns the job-name path segment to append to a storage's base path, honouring storage.IncludeJobName (nil/true → append, false → skip).

func ParseSplitWrapper

func ParseSplitWrapper(name string) (base string, parts int, totalSize int64, ok bool)

func SplitWrapperName

func SplitWrapperName(archiveName string, partsCount int, totalSize int64) string

Types

type BackupSet

type BackupSet struct {
	ID           string
	Files        []FileInfo
	LastModified time.Time
	TotalSize    int64
	IsSplit      bool
	PartsCount   int
	WrapperName  string
}

BackupSet is one logical snapshot. For split snapshots Files is nil — parts inside the wrapper are listed only on demand.

func GroupBackupSets

func GroupBackupSets(files []FileInfo, _ string) []BackupSet

func ListBackupSets

func ListBackupSets(ctx context.Context, st Storage, job *pkgconfig.JobConfig, storageConfig pkgconfig.StorageConfig) ([]BackupSet, error)

ListBackupSets reads through a TTL cache. Callers must InvalidateSetCache after Upload/Delete.

type BunnyStorage

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

func NewBunnyStorage

func NewBunnyStorage() *BunnyStorage

func (*BunnyStorage) DeleteFile

func (b *BunnyStorage) DeleteFile(ctx context.Context, job *pkgconfig.JobConfig, fileName string, storage pkgconfig.StorageConfig) error

func (*BunnyStorage) DeleteWrapper

func (b *BunnyStorage) DeleteWrapper(ctx context.Context, job *pkgconfig.JobConfig, wrapperName string, storage pkgconfig.StorageConfig) error

func (*BunnyStorage) Download

func (b *BunnyStorage) Download(ctx context.Context, job *pkgconfig.JobConfig, wrapperRelDir, fileName string, storage pkgconfig.StorageConfig) (*DownloadResult, error)

func (*BunnyStorage) EnsureJobDir

func (b *BunnyStorage) EnsureJobDir(ctx context.Context, job *pkgconfig.JobConfig, storage pkgconfig.StorageConfig) error

func (*BunnyStorage) GetType

func (b *BunnyStorage) GetType() string

func (*BunnyStorage) ListFiles

func (b *BunnyStorage) ListFiles(ctx context.Context, job *pkgconfig.JobConfig, storage pkgconfig.StorageConfig) ([]FileInfo, error)

func (*BunnyStorage) ListWrapperParts

func (b *BunnyStorage) ListWrapperParts(ctx context.Context, job *pkgconfig.JobConfig, wrapperName string, storage pkgconfig.StorageConfig) ([]FileInfo, error)

func (*BunnyStorage) UploadInto

func (b *BunnyStorage) UploadInto(ctx context.Context, archivePath string, job *pkgconfig.JobConfig, wrapperRelDir string, storage pkgconfig.StorageConfig) error

type DownloadResult

type DownloadResult struct {
	Body        io.ReadCloser
	Size        int64
	RedirectURL string
}

DownloadResult: exactly one of Body or RedirectURL is set.

type Downloader

type Downloader interface {
	Download(ctx context.Context, job *config.JobConfig, wrapperRelDir, fileName string, storage config.StorageConfig) (*DownloadResult, error)
}

Downloader is optional. Storages without it return ErrDownloadNotSupported.

type Factory

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

func NewFactory

func NewFactory() *Factory

func (*Factory) Create

func (f *Factory) Create(storageType string) Storage

func (*Factory) Register

func (f *Factory) Register(storage Storage)

type FileInfo

type FileInfo struct {
	Name         string
	LastModified time.Time
	Size         int64
	// Wrapper is true for split-snapshot wrapper directories.
	Wrapper bool
}

type LocalStorage

type LocalStorage struct{}

func NewLocalStorage

func NewLocalStorage() *LocalStorage

func (*LocalStorage) DeleteFile

func (l *LocalStorage) DeleteFile(ctx context.Context, job *pkgconfig.JobConfig, fileName string, storage pkgconfig.StorageConfig) error

func (*LocalStorage) DeleteWrapper

func (l *LocalStorage) DeleteWrapper(ctx context.Context, job *pkgconfig.JobConfig, wrapperName string, storage pkgconfig.StorageConfig) error

func (*LocalStorage) Download

func (l *LocalStorage) Download(ctx context.Context, job *pkgconfig.JobConfig, wrapperRelDir, fileName string, storage pkgconfig.StorageConfig) (*DownloadResult, error)

func (*LocalStorage) EnsureJobDir

func (l *LocalStorage) EnsureJobDir(ctx context.Context, job *pkgconfig.JobConfig, storage pkgconfig.StorageConfig) error

func (*LocalStorage) GetType

func (l *LocalStorage) GetType() string

func (*LocalStorage) ListFiles

func (l *LocalStorage) ListFiles(ctx context.Context, job *pkgconfig.JobConfig, storage pkgconfig.StorageConfig) ([]FileInfo, error)

func (*LocalStorage) ListWrapperParts

func (l *LocalStorage) ListWrapperParts(ctx context.Context, job *pkgconfig.JobConfig, wrapperName string, storage pkgconfig.StorageConfig) ([]FileInfo, error)

func (*LocalStorage) UploadInto

func (l *LocalStorage) UploadInto(ctx context.Context, archivePath string, job *pkgconfig.JobConfig, wrapperRelDir string, storage pkgconfig.StorageConfig) error

type S3Storage

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

func NewS3Storage

func NewS3Storage() *S3Storage

func (*S3Storage) DeleteFile

func (s *S3Storage) DeleteFile(ctx context.Context, job *pkgconfig.JobConfig, fileName string, storage pkgconfig.StorageConfig) error

func (*S3Storage) DeleteWrapper

func (s *S3Storage) DeleteWrapper(ctx context.Context, job *pkgconfig.JobConfig, wrapperName string, storage pkgconfig.StorageConfig) error

func (*S3Storage) Download

func (s *S3Storage) Download(ctx context.Context, job *pkgconfig.JobConfig, wrapperRelDir, fileName string, storage pkgconfig.StorageConfig) (*DownloadResult, error)

func (*S3Storage) EnsureJobDir

func (s *S3Storage) EnsureJobDir(ctx context.Context, job *pkgconfig.JobConfig, storage pkgconfig.StorageConfig) error

func (*S3Storage) GetType

func (s *S3Storage) GetType() string

func (*S3Storage) ListFiles

func (s *S3Storage) ListFiles(ctx context.Context, job *pkgconfig.JobConfig, storage pkgconfig.StorageConfig) ([]FileInfo, error)

func (*S3Storage) ListWrapperParts

func (s *S3Storage) ListWrapperParts(ctx context.Context, job *pkgconfig.JobConfig, wrapperName string, storage pkgconfig.StorageConfig) ([]FileInfo, error)

func (*S3Storage) UploadInto

func (s *S3Storage) UploadInto(ctx context.Context, archivePath string, job *pkgconfig.JobConfig, wrapperRelDir string, storage pkgconfig.StorageConfig) error

type SFTPStorage

type SFTPStorage struct{}

func NewSFTPStorage

func NewSFTPStorage() *SFTPStorage

func (*SFTPStorage) DeleteFile

func (s *SFTPStorage) DeleteFile(ctx context.Context, job *pkgconfig.JobConfig, fileName string, storage pkgconfig.StorageConfig) error

func (*SFTPStorage) DeleteWrapper

func (s *SFTPStorage) DeleteWrapper(ctx context.Context, job *pkgconfig.JobConfig, wrapperName string, storage pkgconfig.StorageConfig) error

func (*SFTPStorage) Download

func (s *SFTPStorage) Download(ctx context.Context, job *pkgconfig.JobConfig, wrapperRelDir, fileName string, storage pkgconfig.StorageConfig) (*DownloadResult, error)

func (*SFTPStorage) EnsureJobDir

func (s *SFTPStorage) EnsureJobDir(ctx context.Context, job *pkgconfig.JobConfig, storage pkgconfig.StorageConfig) error

func (*SFTPStorage) GetType

func (s *SFTPStorage) GetType() string

func (*SFTPStorage) ListFiles

func (s *SFTPStorage) ListFiles(ctx context.Context, job *pkgconfig.JobConfig, storage pkgconfig.StorageConfig) ([]FileInfo, error)

func (*SFTPStorage) ListWrapperParts

func (s *SFTPStorage) ListWrapperParts(ctx context.Context, job *pkgconfig.JobConfig, wrapperName string, storage pkgconfig.StorageConfig) ([]FileInfo, error)

func (*SFTPStorage) UploadInto

func (s *SFTPStorage) UploadInto(ctx context.Context, archivePath string, job *pkgconfig.JobConfig, wrapperRelDir string, storage pkgconfig.StorageConfig) error

type Storage

type Storage interface {
	// EnsureJobDir is a no-op on object stores.
	EnsureJobDir(ctx context.Context, job *config.JobConfig, storage config.StorageConfig) error
	// UploadInto writes archivePath to <storage.Path>/<jobName>/<wrapperRelDir>/<basename>;
	// wrapperRelDir is "" for non-split.
	UploadInto(ctx context.Context, archivePath string, job *config.JobConfig, wrapperRelDir string, storage config.StorageConfig) error
	ListFiles(ctx context.Context, job *config.JobConfig, storage config.StorageConfig) ([]FileInfo, error)
	ListWrapperParts(ctx context.Context, job *config.JobConfig, wrapperName string, storage config.StorageConfig) ([]FileInfo, error)
	DeleteFile(ctx context.Context, job *config.JobConfig, fileName string, storage config.StorageConfig) error
	DeleteWrapper(ctx context.Context, job *config.JobConfig, wrapperName string, storage config.StorageConfig) error
	GetType() string
}

type WebDAVStorage

type WebDAVStorage struct{}

func NewWebDAVStorage

func NewWebDAVStorage() *WebDAVStorage

func (*WebDAVStorage) DeleteFile

func (w *WebDAVStorage) DeleteFile(ctx context.Context, job *pkgconfig.JobConfig, fileName string, storage pkgconfig.StorageConfig) error

func (*WebDAVStorage) DeleteWrapper

func (w *WebDAVStorage) DeleteWrapper(ctx context.Context, job *pkgconfig.JobConfig, wrapperName string, storage pkgconfig.StorageConfig) error

func (*WebDAVStorage) Download

func (w *WebDAVStorage) Download(ctx context.Context, job *pkgconfig.JobConfig, wrapperRelDir, fileName string, storage pkgconfig.StorageConfig) (*DownloadResult, error)

func (*WebDAVStorage) EnsureJobDir

func (w *WebDAVStorage) EnsureJobDir(ctx context.Context, job *pkgconfig.JobConfig, storage pkgconfig.StorageConfig) error

func (*WebDAVStorage) GetType

func (w *WebDAVStorage) GetType() string

func (*WebDAVStorage) ListFiles

func (w *WebDAVStorage) ListFiles(ctx context.Context, job *pkgconfig.JobConfig, storage pkgconfig.StorageConfig) ([]FileInfo, error)

func (*WebDAVStorage) ListWrapperParts

func (w *WebDAVStorage) ListWrapperParts(ctx context.Context, job *pkgconfig.JobConfig, wrapperName string, storage pkgconfig.StorageConfig) ([]FileInfo, error)

func (*WebDAVStorage) UploadInto

func (w *WebDAVStorage) UploadInto(ctx context.Context, archivePath string, job *pkgconfig.JobConfig, wrapperRelDir string, storage pkgconfig.StorageConfig) error

Jump to

Keyboard shortcuts

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