Documentation
¶
Overview ¶
Package restorer manages the cluster restoration process
Index ¶
- Variables
- type Command
- type Prefetch
- type WALRestorer
- func (restorer *WALRestorer) IsEndOfWALStream() (bool, error)
- func (restorer *WALRestorer) Prefetch(ctx context.Context, p Prefetch) (started int)
- func (restorer *WALRestorer) ResetEndOfWalStream() error
- func (restorer *WALRestorer) Restore(ctx context.Context, walName, destinationPath string, baseOptions []string) error
- func (restorer *WALRestorer) RestoreFromSpool(ctx context.Context, walName, destinationPath string) (wasInSpool bool, err error)
- func (restorer *WALRestorer) RestoreWithPrefetch(ctx context.Context, walName, destinationPath string, p Prefetch) (prefetching int, err error)
- func (restorer *WALRestorer) SetEndOfWALStream() error
Constants ¶
This section is empty.
Variables ¶
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
GetRestoreConfiguration gets the configuration in the `Restore` object of the pgbackrest configuration
type Prefetch ¶ added in v0.10.0
type Prefetch struct {
// WALs are the files to have ready in the spool, nearest first.
WALs []string
// Parallel is the number of downloads that may run at a time, counting the one for
// the file PostgreSQL waits for, so Parallel - 1 are left for the prefetch. When
// Parallel is 1 a single prefetch still runs, for the partial file of a promotion.
Parallel int
// Options are the pgbackrest archive-get options.
Options []string
}
Prefetch describes the WAL files a restore_command call wants downloaded into the spool ahead of PostgreSQL.
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) Prefetch ¶ added in v0.10.0
func (restorer *WALRestorer) Prefetch(ctx context.Context, p Prefetch) (started int)
Prefetch replaces the files wanted in the spool with p.WALs and starts downloading them, nearest first, skipping the ones already in the spool or being downloaded. It returns how many downloads it started.
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( ctx context.Context, 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. If a prefetch is still downloading the file, it waits for it first, and returns ErrWALNotFound when the prefetch found the file missing.
func (*WALRestorer) RestoreWithPrefetch ¶ added in v0.10.0
func (restorer *WALRestorer) RestoreWithPrefetch( ctx context.Context, walName, destinationPath string, p Prefetch, ) (prefetching int, err error)
RestoreWithPrefetch restores walName, the WAL file PostgreSQL requested and did not find in the spool, into destinationPath, and prefetches p in the background. It returns as soon as the requested file is restored or known to be missing, without waiting for the prefetch, together with the number of prefetches it started. Once PostgreSQL asks for a file whose prefetch failed, the prefetch goes past it again.
func (*WALRestorer) SetEndOfWALStream ¶
func (restorer *WALRestorer) SetEndOfWALStream() error
SetEndOfWALStream add end-of-wal-stream in the spool directory