pvebackup

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package pvebackup holds the Proxmox VE host backup job specification and run manifest. It is shared by the server (validation) and the filesystem agent (execution on the PVE node), so it must stay free of process-execution dependencies.

Index

Constants

View Source
const (
	// ArchiveName is the pxar archive holding the host configuration and data paths
	ArchiveName = "pve"
	// ManifestBlobName / ManifestFileName is the run manifest (blob and inside collect/)
	ManifestBlobName = "fallbck-pve.json"
	ManifestFileName = "fallbck-pve.json"
	// RestoreScriptName is the generated restore runbook inside collect/
	RestoreScriptName = "fallbck-pve-restore.sh"
	// CollectEntry is the archive entry holding everything the agent collected
	CollectEntry = "collect"
)

Names inside the snapshot

View Source
const ManifestSchemaVersion = 1

ManifestSchemaVersion is bumped on incompatible manifest changes

Variables

View Source
var ErrInvalidSpec = errors.New("invalid Proxmox VE job configuration")

ErrInvalidSpec wraps every validation failure

Functions

func IsPVEHost

func IsPVEHost() bool

IsPVEHost reports whether this machine is a Proxmox VE node

Types

type ArchiveEntry

type ArchiveEntry struct {
	Name   string `json:"name"`
	Source string `json:"source"`
	// Kind: etc | root | collect | data
	Kind string `json:"kind"`
}

ArchiveEntry maps a top-level archive name to its origin

type Collected

type Collected struct {
	Name    string `json:"name"`
	Command string `json:"command,omitempty"`
	File    string `json:"file,omitempty"`
	Error   string `json:"error,omitempty"`
}

Collected is the outcome of one collector

type Disk

type Disk struct {
	Path           string `json:"path"`
	Model          string `json:"model,omitempty"`
	Serial         string `json:"serial,omitempty"`
	SizeBytes      int64  `json:"size_bytes"`
	PartitionTable string `json:"partition_table,omitempty"` // sgdisk backup file inside collect/
}

Disk is a block device of the host with its saved partition table

type Guest

type Guest struct {
	VMID       int    `json:"vmid"`
	Type       string `json:"type"` // qemu | lxc
	Name       string `json:"name,omitempty"`
	ConfigFile string `json:"config_file"`
}

Guest is a VM or container whose configuration was captured

type HostInfo

type HostInfo struct {
	Hostname   string `json:"hostname"`
	Node       string `json:"node"`
	PVEVersion string `json:"pve_version,omitempty"` // pve-manager version, e.g. 8.2.4
	PVEMajor   int    `json:"pve_major,omitempty"`
	Kernel     string `json:"kernel,omitempty"`
	OS         string `json:"os,omitempty"` // /etc/os-release PRETTY_NAME
}

HostInfo describes the PVE node

type Manifest

type Manifest struct {
	SchemaVersion int               `json:"schema_version"`
	Generator     ManifestGenerator `json:"generator"`
	Job           ManifestJob       `json:"job"`
	Snapshot      ManifestSnapshot  `json:"snapshot"`
	StartedAt     time.Time         `json:"started_at"`
	FinishedAt    time.Time         `json:"finished_at"`
	Host          HostInfo          `json:"host"`
	Packages      PackageInfo       `json:"packages"`
	Storages      []Storage         `json:"storages"`
	Guests        []Guest           `json:"guests"`
	Disks         []Disk            `json:"disks"`
	// Entries maps archive top-level names to their source on the host
	Entries  []ArchiveEntry `json:"entries"`
	Excludes []string       `json:"excludes,omitempty"`
	// Collected records every collector that ran (and how it went)
	Collected []Collected `json:"collected"`
	Spec      *Spec       `json:"spec,omitempty"`
	Warnings  []string    `json:"warnings,omitempty"`
	Restore   Restore     `json:"restore"`
}

Manifest describes one Proxmox VE host backup: what was collected, how the archive is laid out and how to restore it. It is stored as fallbck-pve.json inside the collect/ entry and as a blob next to the archive.

func ParseManifest

func ParseManifest(data []byte) (*Manifest, error)

ParseManifest decodes a manifest

func (*Manifest) Marshal

func (m *Manifest) Marshal() ([]byte, error)

Marshal renders the manifest as indented JSON

type ManifestGenerator

type ManifestGenerator struct {
	Agent    string `json:"agent"`
	Version  string `json:"version"`
	Hostname string `json:"hostname"`
}

ManifestGenerator identifies the agent that produced the backup

type ManifestJob

type ManifestJob struct {
	ID          string `json:"id"`
	Name        string `json:"name,omitempty"`
	RunID       string `json:"run_id"`
	BackupRunID string `json:"backup_run_id"`
}

ManifestJob identifies the job and run

type ManifestSnapshot

type ManifestSnapshot struct {
	Type    string    `json:"type"`
	ID      string    `json:"id"`
	Time    time.Time `json:"time"`
	Archive string    `json:"archive"`
}

ManifestSnapshot is the PBS snapshot identity

type PackageInfo

type PackageInfo struct {
	Installed  int    `json:"installed"`
	Manual     int    `json:"manual"`
	ListFile   string `json:"list_file,omitempty"`
	ManualFile string `json:"manual_file,omitempty"`
}

PackageInfo summarises the dpkg state recorded in collect/

type Restore

type Restore struct {
	Summary  string   `json:"summary"`
	Commands []string `json:"commands"`
	Script   string   `json:"script,omitempty"`
}

Restore carries the runbook: a summary, the commands to run, and the script's location inside the archive

type Spec

type Spec struct {
	// DataPaths are additional directories archived file by file (mounted data
	// storages such as /var/lib/vz or /mnt/pve/<storage>)
	DataPaths []string `json:"data_paths,omitempty"`
	// ExcludePaths are proxmox-backup-client style patterns against archive paths
	ExcludePaths []string `json:"exclude_paths,omitempty"`
	// IncludeRootHome archives /root (default true)
	IncludeRootHome *bool `json:"include_root_home,omitempty"`
	// IncludeGuestImages keeps VM/CT disk images found under the data paths
	// (images/, private/, subvol-*). Default false: vzdump/PBS already cover guests.
	IncludeGuestImages *bool `json:"include_guest_images,omitempty"`
}

Spec is the Proxmox VE job configuration (backup_jobs.pve_config). The host configuration (/etc, /etc/pve, package lists, storage and network definitions, partition tables) is always included; DataPaths adds mounted data filesystems.

func (*Spec) Clone

func (s *Spec) Clone() *Spec

Clone returns a deep copy

func (*Spec) EffIncludeGuestImages

func (s *Spec) EffIncludeGuestImages() bool

func (*Spec) EffIncludeRootHome

func (s *Spec) EffIncludeRootHome() bool

EffIncludeRootHome / EffIncludeGuestImages apply the defaults

func (*Spec) Summary

func (s *Spec) Summary() string

Summary is a short human-readable description (UI tables, logs)

func (*Spec) Validate

func (s *Spec) Validate() error

Validate normalises the data paths and checks the exclude patterns

type Storage

type Storage struct {
	ID       string   `json:"id"`
	Type     string   `json:"type"`
	Path     string   `json:"path,omitempty"`
	Pool     string   `json:"pool,omitempty"`
	Server   string   `json:"server,omitempty"`
	Export   string   `json:"export,omitempty"`
	Content  []string `json:"content,omitempty"`
	Shared   bool     `json:"shared,omitempty"`
	Disabled bool     `json:"disabled,omitempty"`
}

Storage is one entry of /etc/pve/storage.cfg

Jump to

Keyboard shortcuts

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