restorer

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package restorer manages the cluster restoration process

Index

Constants

This section is empty.

Variables

View Source
var ErrWALNotFound = errors.New("WAL not found")

ErrWALNotFound is returned when the WAL is not found in the cloud archive

Functions

This section is empty.

Types

type Command added in v0.2.0

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

Command represents a pgbackrest restore command

func NewRestoreCommand added in v0.2.0

func NewRestoreCommand(
	configuration *pgbackrestApi.PgbackrestConfiguration,
	pgDataDirectory string,
) *Command

NewRestoreCommand creates a new pgbackrest restore command

func (*Command) GetPgbackrestRestoreOptions added in v0.2.0

func (b *Command) GetPgbackrestRestoreOptions(
	ctx context.Context,
	backupName string,
	stanza string,
) ([]string, error)

GetPgbackrestRestoreOptions extract the list of command line options to be used with pgbackrest restore

func (*Command) GetRestoreConfiguration added in v0.2.0

func (b *Command) GetRestoreConfiguration(
	options []string,
) ([]string, error)

GetRestoreConfiguration gets the configuration in the `Restore` object of the pgbackrest configuration

func (*Command) Restore added in v0.2.0

func (b *Command) Restore(
	ctx context.Context,
	backupName string,
	stanza string,
	env []string,
) error

Restore restores a database from backup

type Result

type Result struct {
	// The name of the WAL file to restore
	WalName string

	// Where to store the restored WAL file
	DestinationPath string

	// If not nil, this is the error that has been detected
	Err error

	// The time when we started archive-get
	StartTime time.Time

	// The time when end archive-get ended
	EndTime time.Time
}

Result is the structure filled by the restore process on completion

type WALRestorer

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

WALRestorer is a structure containing every info needed to restore some WALs from the object storage

func NewWALRestorer added in v0.2.0

func NewWALRestorer(
	ctx context.Context,
	env []string,
	spoolDirectory string,
) (restorer *WALRestorer, err error)

NewWALRestorer creates a new WAL restorer

func (*WALRestorer) IsEndOfWALStream

func (restorer *WALRestorer) IsEndOfWALStream() (bool, error)

IsEndOfWALStream check whether end-of-wal-stream flag is presents in the spool directory

func (*WALRestorer) ResetEndOfWalStream

func (restorer *WALRestorer) ResetEndOfWalStream() error

ResetEndOfWalStream remove end-of-wal-stream flag from the spool directory

func (*WALRestorer) Restore

func (restorer *WALRestorer) Restore(
	ctx context.Context,
	walName, destinationPath string,
	baseOptions []string,
) error

Restore restores a WAL file from the object store

func (*WALRestorer) RestoreFromSpool

func (restorer *WALRestorer) RestoreFromSpool(walName, destinationPath string) (wasInSpool bool, err error)

RestoreFromSpool restores a certain file from the spool, returning a boolean flag indicating is the file was in the spool or not. If the file was in the spool, it will be moved into the specified destination path

func (*WALRestorer) RestoreList

func (restorer *WALRestorer) RestoreList(
	ctx context.Context,
	fetchList []string,
	destinationPath string,
	options []string,
) (resultList []Result)

RestoreList restores a list of WALs. The first WAL of the list will go directly into the destination path, the others will be adopted by the spool

func (*WALRestorer) SetEndOfWALStream

func (restorer *WALRestorer) SetEndOfWALStream() error

SetEndOfWALStream add end-of-wal-stream in the spool directory

Jump to

Keyboard shortcuts

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