domain

package
v1.0.0-beta.5 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const StateFileName = ".backupstate.yaml"

Variables

View Source
var DefaultVolumeGroup = "default"
View Source
var ErrNoLocalTrimPolicy = errors.New("no local trim policy configured")
View Source
var ErrNoRemoteTrimPolicy = errors.New("no remote trim policy configured")
View Source
var ErrNotFound = errors.New("object not found")

Functions

func ChainMiddlewareRead

func ChainMiddlewareRead(m []Middleware) func(io.Reader) (io.Reader, error)

func ChainMiddlewareWrite

func ChainMiddlewareWrite(m []Middleware) func(io.Writer) (io.Writer, error)

Types

type BackupCreate

type BackupCreate struct {
	Snapshot         ZfsSnapshot
	PreviousSnapshot *ZfsSnapshot
	ProxyReaderFunc  func(r io.Reader) (io.Reader, error)
}

type BackupDelete

type BackupDelete struct {
	BlobKey string
}

type BackupListUsecase

type BackupListUsecase interface {
	List(ctx context.Context, volumeName string, writer io.Writer) error
}

type BackupRecord

type BackupRecord struct {
	Type            BackupType `yaml:"type"`
	ParentBackupKey string     `yaml:"parent-backup-key"`
	Size            *int64     `yaml:"size,omitempty"`
}

type BackupRecordWithKey

type BackupRecordWithKey struct {
	BackupRecord
	Key string
}

func (*BackupRecordWithKey) GetFileName

func (b *BackupRecordWithKey) GetFileName() string

type BackupRepository

type BackupRepository interface {
	Create(ctx context.Context, p *BackupCreate) (*UploadResponse, error)
	Restore(ctx context.Context, p *BackupRestore) error
	Delete(ctx context.Context, bd *BackupDelete) error
}

type BackupRequest

type BackupRequest struct {
	Snapshot *ZfsSnapshot
	IsHead   bool
	Type     BackupType
}

type BackupRestore

type BackupRestore struct {
	TargetZfsLocation string
	BlobKey           string
	ProxyWriterFunc   func(w io.Writer) (io.Writer, error)
}

type BackupState

type BackupState struct {
	Head    string                  `yaml:"head"`
	Backups map[string]BackupRecord `yaml:"backups"`
}

func (*BackupState) DeleteBackup

func (b *BackupState) DeleteBackup(key string)

func (*BackupState) GetRecordByKey

func (b *BackupState) GetRecordByKey(key string) (r *BackupRecordWithKey, err error)

func (*BackupState) VisitParent

func (b *BackupState) VisitParent(startNode *BackupRecordWithKey, f func(r *BackupRecordWithKey) bool) error

type BackupStateRepo

type BackupStateRepo interface {
	Download(ctx context.Context, key string) (*BackupState, error)
	DownloadOrDefault(ctx context.Context, key string) (*BackupState, error)
	UpdateState(ctx context.Context, stateFileKey string, f func(state *BackupState) error) error
	Upload(ctx context.Context, key string, state *BackupState) error
}

type BackupSyncUsecase

type BackupSyncUsecase interface {
	Backup(ctx context.Context, groupName string) error
	CalcSnapsToBackup(bs *BackupState, snaps []*ZfsSnapshot) ([]*BackupRequest, error)
}

type BackupType

type BackupType int
const (
	Unknown BackupType = iota
	Full
	Incremental
)

func StringToBackupType

func StringToBackupType(str string) BackupType

func (BackupType) String

func (s BackupType) String() string

type BackupUsecase

type BackupUsecase interface {
	BackupFull(ctx context.Context, fullSnapName string, updateHead bool) error
	BackupIncremental(ctx context.Context, baseSnapName, newSnapName string, updateHead bool) error
	Restore(ctx context.Context, params *RestoreParams) error
}

type Commander

type Commander = func(name string, arg ...string) *exec.Cmd

type DeleteParameters

type DeleteParameters struct {
	Bucket string
	Key    string
}

type DeleteResult

type DeleteResult struct {
	Delete         []*BackupRecordWithKey
	DependentsKeys map[string]bool
}

type DownloadParameters

type DownloadParameters struct {
	Bucket string
	Key    string
}

type FilterCriteria

type FilterCriteria struct {
	VolumeName                 string
	IgnoreInvalidSnapshotNames bool
}

type ListParameters

type ListParameters struct {
	Type   []string
	Fields []string
}

type LogDriver

type LogDriver interface {
	Debugf(format string, v ...interface{})
	Infof(format string, v ...interface{})
}

type LogLevel

type LogLevel int
const (
	UnknownLevel LogLevel = iota
	DebugLevel
	InfoLevel
)

func StringToLevel

func StringToLevel(s string) LogLevel

func (LogLevel) ToZeroLevel

func (l LogLevel) ToZeroLevel() zerolog.Level

type LogRepository

type LogRepository interface {
	LogDriver
}

type Middleware

type Middleware interface {
	Write(w io.Writer) (wp io.Writer, err error)
	Read(r io.Reader) (rp io.Reader, err error)
}

type Nower

type Nower interface {
	Now() time.Time
}

type ReceiveParameters

type ReceiveParameters struct {
	TargetName string
}

type RenderDriver

type RenderDriver interface {
	RenderTable(writer io.Writer, headerRow []interface{}, rows [][]interface{})
}

type RenderRepository

type RenderRepository interface {
	RenderBackupTable(writer io.Writer, backups []BackupRecordWithKey)
	RenderVolumeTable(writer io.Writer, volumes []*ZfsVolume)
}

type RestoreParams

type RestoreParams struct {
	TargetZfsLocation string
	BlobKey           string
	RestoreAll        bool
}

type SendParameters

type SendParameters struct {
	WithParameters       bool
	PreviousSnapshotName string
	SnapshotName         string
}

type SnapshotNamestrategy

type SnapshotNamestrategy interface {
	GetName() string
	IsMatching(snapshotName string) bool
	IsGreater(snapNameA, snapNameB string) bool
}

type SnapshotRepository

type SnapshotRepository interface {
	Create(v *ZfsVolume) (string, error)
	CreateWithType(v *ZfsVolume, t BackupType) (string, error)
	List() ([]*ZfsSnapshot, error)
	ListFilter(filter *FilterCriteria) ([]*ZfsSnapshot, error)
	GetType(zfsEntity string) (BackupType, error)
	Delete(snap *ZfsSnapshot) error
}

type SnapshotUsecase

type SnapshotUsecase interface {
	CreateByGroup(groupName string, backupType string) error
	CreateByVolume(volume *ZfsVolume, backupType BackupType) error
}

type StorageDriver

type StorageDriver interface {
	Delete(ctx context.Context, dp *DeleteParameters) error
	Upload(ctx context.Context, up *UploadParameters, reader io.Reader) (*UploadResponse, error)
	Download(ctx context.Context, dp *DownloadParameters, writer io.Writer) error
}

type TrimLocalParameters

type TrimLocalParameters struct {
	GroupName string
	DryRun    bool
}

type TrimRemoteParameters

type TrimRemoteParameters struct {
	GroupName string
	DryRun    bool
}

type TrimUsecase

type TrimUsecase interface {
	TrimRemote(ctx context.Context, pa *TrimRemoteParameters) error
	TrimLocal(_ context.Context, pa *TrimLocalParameters) error
}

type UploadParameters

type UploadParameters struct {
	Bucket string
	Key    string
}

type UploadResponse

type UploadResponse struct {
	Size int64
}

type VolumeRepository

type VolumeRepository interface {
	ListVolumes() ([]*ZfsVolume, error)
	ListVolumesByGroup(groupName string) ([]*ZfsVolume, error)
	TagVolumeWithGroup(volume *ZfsVolume) error
}

type VolumeUsecase

type VolumeUsecase interface {
	List(writer io.Writer) error
	AddToGroup(volumeName, groupName string) error
}

type ZfsDriver

type ZfsDriver interface {
	Send(p *SendParameters) *exec.Cmd
	Snapshot(name string) *exec.Cmd
	List(p *ListParameters) *exec.Cmd
	Receive(p *ReceiveParameters) *exec.Cmd
	GetField(fieldName string, zfsEntity string) *exec.Cmd
	SetField(fieldName, value, zfsEntity string) error
	Destroy(zfsEntity string) error
}

type ZfsSnapshot

type ZfsSnapshot struct {
	Name       string
	VolumeName string
}

func NewZfsSnapshot

func NewZfsSnapshot(fullName string) *ZfsSnapshot

func (ZfsSnapshot) FullName

func (z ZfsSnapshot) FullName() string

func (ZfsSnapshot) NormalizedFullPath

func (z ZfsSnapshot) NormalizedFullPath() string

type ZfsSnapshotWithType

type ZfsSnapshotWithType struct {
	ZfsSnapshot
	Type BackupType
}

type ZfsVolume

type ZfsVolume struct {
	Name      string
	GroupName string
}

Directories

Path Synopsis
mocks
Package mocks_config is a generated GoMock package.
Package mocks_config is a generated GoMock package.
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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