storage

package
v0.0.0-...-890248b Latest Latest
Warning

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

Go to latest
Published: May 21, 2026 License: AGPL-3.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AzureBlobConfig

type AzureBlobConfig struct {
	// AccountName is the Azure storage account name
	AccountName string

	// AccountKey is the Azure storage account key
	AccountKey string

	// ConnectionString is the full connection string (alternative to AccountName/Key)
	ConnectionString string

	// ContainerName is the Azure blob container name
	ContainerName string

	// Prefix is the blob prefix for all backups
	Prefix string

	// Endpoint is the custom endpoint URL (optional, for government/China clouds)
	Endpoint string
}

AzureBlobConfig contains Azure Blob storage configuration.

type AzureBlobStorage

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

AzureBlobStorage implements backup.Storage for Azure Blob storage.

func NewAzureBlobStorage

func NewAzureBlobStorage(ctx context.Context, cfg AzureBlobConfig) (*AzureBlobStorage, error)

NewAzureBlobStorage creates a new Azure Blob storage backend.

func (*AzureBlobStorage) Close

func (s *AzureBlobStorage) Close() error

Close releases any resources.

func (*AzureBlobStorage) ContainerName

func (s *AzureBlobStorage) ContainerName() string

ContainerName returns the Azure container name.

func (*AzureBlobStorage) CopyBlob

func (s *AzureBlobStorage) CopyBlob(ctx context.Context, srcPath, dstPath string) error

CopyBlob copies a blob within Azure storage.

func (*AzureBlobStorage) Delete

func (s *AzureBlobStorage) Delete(ctx context.Context, path string) error

Delete removes a backup from Azure Blob storage.

func (*AzureBlobStorage) Exists

func (s *AzureBlobStorage) Exists(ctx context.Context, path string) (bool, error)

Exists checks if a backup exists.

func (*AzureBlobStorage) GenerateSASURL

func (s *AzureBlobStorage) GenerateSASURL(ctx context.Context, path string, expiry time.Duration) (string, error)

GenerateSASURL generates a SAS URL for downloading a backup.

func (*AzureBlobStorage) List

func (s *AzureBlobStorage) List(ctx context.Context, prefix string) ([]backup.StorageEntry, error)

List lists backups with optional prefix.

func (*AzureBlobStorage) Prefix

func (s *AzureBlobStorage) Prefix() string

Prefix returns the blob prefix.

func (*AzureBlobStorage) Read

func (s *AzureBlobStorage) Read(ctx context.Context, path string) (io.ReadCloser, error)

Read returns a reader for the backup at path.

func (*AzureBlobStorage) Size

func (s *AzureBlobStorage) Size(ctx context.Context, path string) (int64, error)

Size returns the size of a backup in bytes.

func (*AzureBlobStorage) Stats

Stats returns storage statistics.

func (*AzureBlobStorage) Type

func (s *AzureBlobStorage) Type() string

Type returns the storage type identifier.

func (*AzureBlobStorage) Write

func (s *AzureBlobStorage) Write(ctx context.Context, path string, reader io.Reader, size int64) error

Write writes data to Azure Blob storage.

type B2Config

type B2Config struct {
	// KeyID is the Backblaze B2 Application Key ID
	KeyID string

	// ApplicationKey is the Backblaze B2 Application Key
	ApplicationKey string

	// Bucket is the B2 bucket name
	Bucket string

	// Region is the B2 region (e.g., "us-west-002", "eu-central-003")
	Region string

	// Prefix is the key prefix for all backups
	Prefix string
}

B2Config contains B2 storage configuration.

type B2Storage

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

B2Storage implements backup.Storage for Backblaze B2 storage using S3-compatible API.

func NewB2Storage

func NewB2Storage(ctx context.Context, cfg B2Config) (*B2Storage, error)

NewB2Storage creates a new Backblaze B2 storage backend.

func (*B2Storage) Bucket

func (s *B2Storage) Bucket() string

Bucket returns the B2 bucket name.

func (*B2Storage) Close

func (s *B2Storage) Close() error

Close releases any resources.

func (*B2Storage) CopyObject

func (s *B2Storage) CopyObject(ctx context.Context, srcPath, dstPath string) error

CopyObject copies an object within B2.

func (*B2Storage) Delete

func (s *B2Storage) Delete(ctx context.Context, path string) error

Delete removes a backup from B2.

func (*B2Storage) Exists

func (s *B2Storage) Exists(ctx context.Context, path string) (bool, error)

Exists checks if a backup exists.

func (*B2Storage) GeneratePresignedURL

func (s *B2Storage) GeneratePresignedURL(ctx context.Context, path string, expiry time.Duration) (string, error)

GeneratePresignedURL generates a presigned URL for downloading a backup.

func (*B2Storage) List

func (s *B2Storage) List(ctx context.Context, prefix string) ([]backup.StorageEntry, error)

List lists backups with optional prefix.

func (*B2Storage) Prefix

func (s *B2Storage) Prefix() string

Prefix returns the key prefix.

func (*B2Storage) Read

func (s *B2Storage) Read(ctx context.Context, path string) (io.ReadCloser, error)

Read returns a reader for the backup at path.

func (*B2Storage) Size

func (s *B2Storage) Size(ctx context.Context, path string) (int64, error)

Size returns the size of a backup in bytes.

func (*B2Storage) Stats

func (s *B2Storage) Stats(ctx context.Context) (*backup.StorageStats, error)

Stats returns storage statistics.

func (*B2Storage) Type

func (s *B2Storage) Type() string

Type returns the storage type identifier.

func (*B2Storage) Write

func (s *B2Storage) Write(ctx context.Context, path string, reader io.Reader, size int64) error

Write writes data to B2 storage.

type LocalStorage

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

LocalStorage implements backup.Storage for local filesystem storage.

func NewLocalStorage

func NewLocalStorage(basePath string) (*LocalStorage, error)

NewLocalStorage creates a new local storage backend.

func (*LocalStorage) BasePath

func (s *LocalStorage) BasePath() string

BasePath returns the base storage path.

func (*LocalStorage) Close

func (s *LocalStorage) Close() error

Close releases any resources.

func (*LocalStorage) CreateSubdir

func (s *LocalStorage) CreateSubdir(name string) (string, error)

CreateSubdir creates a subdirectory in the storage path.

func (*LocalStorage) Delete

func (s *LocalStorage) Delete(ctx context.Context, path string) error

Delete removes a backup from storage.

func (*LocalStorage) EnsureSpace

func (s *LocalStorage) EnsureSpace(ctx context.Context, requiredBytes int64) error

EnsureSpace checks if there's enough space for a backup.

func (*LocalStorage) Exists

func (s *LocalStorage) Exists(ctx context.Context, path string) (bool, error)

Exists checks if a backup exists.

func (*LocalStorage) GetLastModified

func (s *LocalStorage) GetLastModified(ctx context.Context, path string) (time.Time, error)

GetLastModified returns the last modification time of a backup.

func (*LocalStorage) List

func (s *LocalStorage) List(ctx context.Context, prefix string) ([]backup.StorageEntry, error)

List lists backups with optional prefix.

func (*LocalStorage) Read

func (s *LocalStorage) Read(ctx context.Context, path string) (io.ReadCloser, error)

Read returns a reader for the backup at path.

func (*LocalStorage) Size

func (s *LocalStorage) Size(ctx context.Context, path string) (int64, error)

Size returns the size of a backup in bytes.

func (*LocalStorage) Stats

Stats returns storage statistics.

func (*LocalStorage) Type

func (s *LocalStorage) Type() string

Type returns the storage type identifier.

func (*LocalStorage) Write

func (s *LocalStorage) Write(ctx context.Context, path string, reader io.Reader, size int64) error

Write writes data to storage.

type S3Config

type S3Config struct {
	// Endpoint is the S3 endpoint URL (for MinIO, etc.)
	// Leave empty for AWS S3
	Endpoint string

	// Region is the AWS region
	Region string

	// Bucket is the S3 bucket name
	Bucket string

	// Prefix is the key prefix for all backups
	Prefix string

	// AccessKey is the AWS access key
	AccessKey string

	// SecretKey is the AWS secret key
	SecretKey string

	// UsePathStyle enables path-style addressing (required for MinIO)
	UsePathStyle bool
}

S3Config contains S3 storage configuration.

type S3Storage

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

S3Storage implements backup.Storage for S3-compatible storage.

func NewS3Storage

func NewS3Storage(ctx context.Context, cfg S3Config) (*S3Storage, error)

NewS3Storage creates a new S3 storage backend.

func (*S3Storage) Bucket

func (s *S3Storage) Bucket() string

Bucket returns the S3 bucket name.

func (*S3Storage) Close

func (s *S3Storage) Close() error

Close releases any resources.

func (*S3Storage) CopyObject

func (s *S3Storage) CopyObject(ctx context.Context, srcPath, dstPath string) error

CopyObject copies an object within S3.

func (*S3Storage) Delete

func (s *S3Storage) Delete(ctx context.Context, path string) error

Delete removes a backup from S3.

func (*S3Storage) Exists

func (s *S3Storage) Exists(ctx context.Context, path string) (bool, error)

Exists checks if a backup exists.

func (*S3Storage) GeneratePresignedURL

func (s *S3Storage) GeneratePresignedURL(ctx context.Context, path string, expiry time.Duration) (string, error)

GeneratePresignedURL generates a presigned URL for downloading a backup.

func (*S3Storage) List

func (s *S3Storage) List(ctx context.Context, prefix string) ([]backup.StorageEntry, error)

List lists backups with optional prefix.

func (*S3Storage) Prefix

func (s *S3Storage) Prefix() string

Prefix returns the S3 key prefix.

func (*S3Storage) Read

func (s *S3Storage) Read(ctx context.Context, path string) (io.ReadCloser, error)

Read returns a reader for the backup at path.

func (*S3Storage) Size

func (s *S3Storage) Size(ctx context.Context, path string) (int64, error)

Size returns the size of a backup in bytes.

func (*S3Storage) Stats

func (s *S3Storage) Stats(ctx context.Context) (*backup.StorageStats, error)

Stats returns storage statistics.

func (*S3Storage) Type

func (s *S3Storage) Type() string

Type returns the storage type identifier.

func (*S3Storage) Write

func (s *S3Storage) Write(ctx context.Context, path string, reader io.Reader, size int64) error

Write writes data to S3.

type SFTPConfig

type SFTPConfig struct {
	// Host is the SFTP server hostname
	Host string

	// Port is the SFTP server port (default: 22)
	Port int

	// Username is the SSH username
	Username string

	// Password is the SSH password (optional if using key)
	Password string

	// PrivateKey is the SSH private key (PEM encoded)
	PrivateKey string

	// PrivateKeyPassphrase is the passphrase for the private key
	PrivateKeyPassphrase string

	// KnownHostsFile is the path to the known_hosts file (optional)
	KnownHostsFile string

	// HostKeyFingerprint is the expected SSH host key fingerprint (SHA256:...).
	// If set, only this fingerprint is accepted. Takes precedence over KnownHostsFile.
	HostKeyFingerprint string

	// InsecureIgnoreHostKey skips host key verification (not recommended)
	InsecureIgnoreHostKey bool

	// BasePath is the base directory on the SFTP server
	BasePath string

	// ConnectTimeout is the connection timeout
	ConnectTimeout time.Duration
}

SFTPConfig contains SFTP storage configuration.

type SFTPStorage

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

SFTPStorage implements backup.Storage for SFTP storage.

func NewSFTPStorage

func NewSFTPStorage(ctx context.Context, cfg SFTPConfig) (*SFTPStorage, error)

NewSFTPStorage creates a new SFTP storage backend.

func (*SFTPStorage) Close

func (s *SFTPStorage) Close() error

Close closes the SFTP connection.

func (*SFTPStorage) Delete

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

Delete removes a backup from storage.

func (*SFTPStorage) Exists

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

Exists checks if a backup exists.

func (*SFTPStorage) GetLastModified

func (s *SFTPStorage) GetLastModified(ctx context.Context, filePath string) (time.Time, error)

GetLastModified returns the last modification time of a backup.

func (*SFTPStorage) List

func (s *SFTPStorage) List(ctx context.Context, prefix string) ([]backup.StorageEntry, error)

List lists backups with optional prefix.

func (*SFTPStorage) Read

func (s *SFTPStorage) Read(ctx context.Context, filePath string) (io.ReadCloser, error)

Read returns a reader for the backup at path.

func (*SFTPStorage) Reconnect

func (s *SFTPStorage) Reconnect(ctx context.Context) error

Reconnect attempts to reconnect to the SFTP server.

func (*SFTPStorage) SetPermissions

func (s *SFTPStorage) SetPermissions(ctx context.Context, filePath string, mode os.FileMode) error

SetPermissions sets file permissions on the SFTP server.

func (*SFTPStorage) Size

func (s *SFTPStorage) Size(ctx context.Context, filePath string) (int64, error)

Size returns the size of a backup in bytes.

func (*SFTPStorage) Stats

func (s *SFTPStorage) Stats(ctx context.Context) (*backup.StorageStats, error)

Stats returns storage statistics.

func (*SFTPStorage) Type

func (s *SFTPStorage) Type() string

Type returns the storage type identifier.

func (*SFTPStorage) Write

func (s *SFTPStorage) Write(ctx context.Context, filePath string, reader io.Reader, size int64) error

Write writes data to SFTP storage.

Jump to

Keyboard shortcuts

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