backup

package
v0.9.0-rc.53 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: AGPL-3.0 Imports: 21 Imported by: 0 modules, 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

Index

Constants

View Source
const (
	// Format is the version of the layout inside the archive, not of pwikit. It
	// changes only when an older build could no longer read a newer file.
	Format = 1

	ManifestName = "manifest.json"

	Extension = ".pwbak"
)
View Source
const MinimumPGVersion = 140000

A newer server is not refused, since nothing in the schema depends on what the versions above this one changed.

Variables

View Source
var ErrNotEmpty = errors.New("the database already holds data")

Functions

func CheckServer

func CheckServer(ctx context.Context, dsn string) (int, error)

This only answers for a server somebody else runs. The bundled one is read off its own data directory before it is even started.

func DefaultName

func DefaultName(at time.Time, site string) string

func Describe

func Describe(num int) string

func Ready

func Ready(ctx context.Context, dsn string, force bool) (holdsData bool, err error)

func TooOld

func TooOld(found int) error

TooOld is what a server below MinimumPGVersion gets told, in the words of somebody who has never heard of a server_version_num.

Types

type CreateOptions

type CreateOptions struct {
	DSN    string
	Files  string
	Output string
	// Site narrows the backup to one site, leaving the rest of the instance
	// behind. Empty takes everything.
	Site          string
	KeepPasswords bool
	Report        func(string)
}

type CreateResult

type CreateResult struct {
	Path     string
	Manifest Manifest
	Bytes    int64
}

func Create

func Create(ctx context.Context, opts CreateOptions) (CreateResult, error)

type Entry

type Entry struct {
	Path     string
	Bytes    int64
	Manifest Manifest
	Problem  string
}

func List

func List(dir string) ([]Entry, error)

A file this cannot read is reported rather than skipped, since a backup nobody can open is the one worth hearing about.

type Files

type Files struct {
	Included bool              `json:"included"`
	Count    int               `json:"count"`
	Bytes    int64             `json:"bytes"`
	Entries  map[string]string `json:"entries"`
}

type Manifest

type Manifest struct {
	Format     int       `json:"format"`
	CreatedAt  time.Time `json:"created_at"`
	Pwikit     string    `json:"pwikit_version"`
	PGVersion  int       `json:"pg_version"`
	Migrations []string  `json:"migrations"`
	// Site is empty for a whole instance and the slug when one site was taken
	// out on its own.
	Site          string           `json:"site,omitempty"`
	KeptPasswords bool             `json:"kept_passwords,omitempty"`
	Tables        map[string]Table `json:"tables"`
	Files         Files            `json:"files"`
}

func ReadManifestOf

func ReadManifestOf(name string) (Manifest, error)

func (Manifest) TotalRows

func (m Manifest) TotalRows() int64

type Report

type Report struct {
	Manifest Manifest
	Problems []string
	Notes    []string
}

func Verify

func Verify(name string) (Report, error)

Verify reads the whole archive rather than trusting the manifest, and keeps going after the first complaint so one run tells you everything.

func (Report) OK

func (r Report) OK() bool

type RestoreOptions

type RestoreOptions struct {
	DSN    string
	Files  string
	Force  bool
	Report func(string)
}

type RestoreResult

type RestoreResult struct {
	Manifest    Manifest
	Rows        int64
	FilesPut    int
	MigratedUp  []string
	FilesMoved  bool
	ReplacedDir string
}

func Restore

func Restore(ctx context.Context, name string, opts RestoreOptions) (RestoreResult, error)

type Table

type Table struct {
	Rows   int64  `json:"rows"`
	Bytes  int64  `json:"bytes"`
	SHA256 string `json:"sha256"`
}

Jump to

Keyboard shortcuts

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