backup

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const MaxSize = 16 << 20
View Source
const SchemaVersion = 1

Variables

View Source
var ErrInvalid = errors.New("invalid backup")

Functions

func IsInvalid

func IsInvalid(err error) bool

func Parse

func Parse(data []byte) (File, Preview, error)

func Validate

func Validate(ctx context.Context, f File) error

Validate 在独立临时库中执行完整恢复,再检查引用和索引。

func WriteAtomic

func WriteAtomic(path string, data []byte) error

WriteAtomic writes one private backup in the data directory and fsyncs it before rename.

Types

type File

type File struct {
	SchemaVersion int                         `yaml:"schema_version" json:"schema_version"`
	Kind          string                      `yaml:"kind" json:"kind"`
	ExportedAt    string                      `yaml:"exported_at" json:"exported_at"`
	Tables        map[string][]map[string]any `yaml:"tables" json:"tables"`
}

type Pending

type Pending struct {
	ID        string  `json:"id"`
	Kind      string  `json:"kind"`
	Proposer  string  `json:"proposer"`
	CreatedAt string  `json:"created_at"`
	State     string  `json:"state"`
	Preview   Preview `json:"preview"`
}

type Preview

type Preview struct {
	Kind   string         `json:"kind"`
	Counts map[string]int `json:"counts"`
}

type Service

type Service struct{ DB *sql.DB }

func (Service) Export

func (s Service) Export(ctx context.Context, kind string) ([]byte, error)

func (Service) List

func (s Service) List(ctx context.Context) ([]Pending, error)

func (Service) Restore

func (s Service) Restore(ctx context.Context, f File) error

func (Service) Review

func (s Service) Review(ctx context.Context, id string, approve bool) error

func (Service) Submit

func (s Service) Submit(ctx context.Context, data []byte, proposer string, allowFull bool) (Pending, error)

Jump to

Keyboard shortcuts

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