hooks

package
v1.123.2 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: Apache-2.0 Imports: 11 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package hooks runs the shell commands a backup is wrapped in.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Redirect

func Redirect(output string) string

Redirect returns the directory a pre hook asked the walk to read instead of the configured root, given as a GOBACK_ROOT=<dir> line on its stdout. The last such line wins; "" means no redirect.

Types

type Runner

type Runner struct {
	Pre  string
	Post string
	// Timeout bounds each hook; 0 means none.
	Timeout time.Duration
	// Stdout and Stderr receive the hooks' output; nil means the process's.
	Stdout io.Writer
	Stderr io.Writer
	// Logger is where the runner reports; nil means slog.Default.
	Logger *slog.Logger
}

Runner runs a backup's pre and post hooks through the system shell. Post runs under its own deadline even when the context is cancelled, so a quiesced server is released after an interrupted walk.

func (*Runner) RunPost

func (r *Runner) RunPost(ctx context.Context) error

RunPost runs the post hook, ignoring the context's cancellation.

func (*Runner) RunPre

func (r *Runner) RunPre(ctx context.Context) (string, error)

RunPre runs the pre hook and returns what it printed to stdout: its first 64 KiB, and the last GOBACK_ROOT line after them.

Jump to

Keyboard shortcuts

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