repository

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBackupCreatedInFuture   = errors.New("backup created in the future")
	ErrFullBackupHasParent     = errors.New("full backup depends on a parent backup")
	ErrDiffBackupNoParent      = errors.New("diff backup does not depend on a parent backup")
	ErrDiffBackupParentNotFull = errors.New("diff backup depends on a parent backup that is not a full backup")
	ErrIncrBackupNoParent      = errors.New("incremental backup does not depend on a parent backup")
	ErrIncrBackupParentNotDiff = errors.New("incremental backup depends on a parent backup that is not a diff backup")
	ErrUnknownBackupType       = errors.New("unknown backup type")
	ErrBackupIDMismatch        = errors.New("backup ID mismatch")
	ErrParentBackupNotFound    = errors.New("parent backup not found")
)

Error variables for backup validation

View Source
var (
	ErrInvalidStoreVersion  = errors.New("invalid store version")
	ErrStoreCreatedInFuture = errors.New("store created in the future")
	ErrBackupInOrphan       = errors.New("backup is in orphan list")
	ErrBackupValidation     = errors.New("backup validation failed")
)

Functions

This section is empty.

Types

type Backup

type Backup struct {
	ID        ulid.ULID  `json:"id"`
	Type      BackupType `json:"type"`
	CreatedAt time.Time  `json:"created_at"`
	DependsOn *ulid.ULID `json:"depends_on"`
	Dataset   string     `json:"dataset"`
	Size      int64      `json:"size"`
}

type BackupType

type BackupType string
const (
	BackupTypeFull BackupType = "full"
	BackupTypeDiff BackupType = "diff"
	BackupTypeIncr BackupType = "incr"
)

type Backups

type Backups map[ulid.ULID]*Backup

func (Backups) Expired

func (bs Backups) Expired(id ulid.ULID, expiry *config.Expiry) (bool, error)

Expired returns true if the backup is expired. Backups expire when their time is lapsed, or when their parent is expired.

func (Backups) ExpiredBackupsForDataset

func (bs Backups) ExpiredBackupsForDataset(dataset string, expiry *config.Expiry) (Backups, error)

func (Backups) GetAllChildren

func (bs Backups) GetAllChildren(id ulid.ULID) Backups

func (Backups) GetChildren

func (bs Backups) GetChildren(id ulid.ULID) Backups

func (Backups) GetParent

func (bs Backups) GetParent(dataset string, typ BackupType) (*Backup, error)

func (Backups) LatestDiff

func (bs Backups) LatestDiff(dataset string) *Backup

LatestDiff returns the latest diff backup.

func (Backups) LatestFull

func (bs Backups) LatestFull(dataset string) *Backup

LatestFull returns the latest full backup.

func (Backups) LatestIncr

func (bs Backups) LatestIncr(dataset string) *Backup

LatestIncr returns the latest incremental backup.

func (Backups) RemoveBackup

func (bs Backups) RemoveBackup(id ulid.ULID) error

func (Backups) TimeTillExpiry

func (bs Backups) TimeTillExpiry(id ulid.ULID, expiry *config.Expiry) (time.Duration, error)

func (Backups) Validate

func (bs Backups) Validate(id ulid.ULID) error

Validate validates the backup identified by id and its parent chain.

type Orphan

type Orphan struct {
	Backup Backup       `json:"backup"`
	Reason OrphanReason `json:"reason"`
}

func (*Orphan) SafeToDelete

func (o *Orphan) SafeToDelete() bool

type OrphanReason

type OrphanReason string
const (
	OrphanReasonUncommitted     OrphanReason = "uncommitted"
	OrphanReasonStartedDeletion OrphanReason = "started_deletion"
)

type Orphans

type Orphans map[ulid.ULID]*Orphan

type Store

type Store struct {
	Version         int               `json:"version"`
	CreatedAt       time.Time         `json:"created_at"`
	Backups         Backups           `json:"backups"`
	Orphans         Orphans           `json:"orphans"`
	Encryption      config.Encryption `json:"encryption"`
	ManagedDatasets []string          `json:"managed_datasets"`
	Hash            *string           `json:"hash"`
}

Store is the main struct that contains the backups and orphans. It is made to be stored in a single file, usually on the same filesystem as the zfsbackrest repository.

func LoadStore

func LoadStore(ctx context.Context, storage storage.StrongStore) (*Store, error)

func (*Store) AddBackup

func (s *Store) AddBackup(ctx context.Context, backup Backup) error

func (*Store) AddOrphan

func (s *Store) AddOrphan(ctx context.Context, backup Backup, reason OrphanReason) error

func (*Store) RemoveOrphan

func (s *Store) RemoveOrphan(ctx context.Context, backup Backup) error

func (*Store) Save

func (s *Store) Save(ctx context.Context, storage storage.StrongStore) error

func (*Store) Validate

func (s *Store) Validate() error

Jump to

Keyboard shortcuts

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