backup

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2026 License: Apache-2.0 Imports: 11 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

Overview

Package backup copies everything Antares keeps into one file, and puts it back.

Everything worth keeping is in one directory, so a backup is a tarball of that directory minus the parts that regenerate themselves. The point of having it in-process rather than telling people to run tar is that the database has to be quiesced first — copying a SQLite file mid-write produces an archive that restores into a corrupt database.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Prune

func Prune(dir string, keep int) (int, error)

Prune keeps the newest n archives and deletes the rest.

func Restore

func Restore(archive, home string, force bool) (int, error)

Restore unpacks an archive over home.

It refuses to overwrite a directory that already holds a database unless force is set: restoring onto a running instance would replace the very state it is using, which is almost never what someone means.

Types

type Info

type Info struct {
	Path      string    `json:"path"`
	Name      string    `json:"name"`
	Size      int64     `json:"size"`
	CreatedAt time.Time `json:"created_at"`
}

Info describes one archive.

func Create

func Create(home, dir, version string, extra []string, quiesce func() error) (Info, error)

Create writes a gzipped tar of home into dir and returns what it wrote.

extra names files outside the state directory that belong in the backup — in practice a SQLite database whose DSN points somewhere else. Without this the archive would silently omit the one thing it exists to protect.

quiesce is called before reading anything and is where the caller checkpoints the database; without it the archive can hold a torn file.

func List

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

List reports the archives in a directory, newest first.

Jump to

Keyboard shortcuts

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