backup

package
v0.0.0-...-ff431e1 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2026 License: AGPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const WorkingDirPrefix = "lxd_backup"

WorkingDirPrefix is used when temporary working directories are needed.

Variables

This section is empty.

Functions

func ConfigToInstanceDBArgs

func ConfigToInstanceDBArgs(state *state.State, c *config.Config, projectName string, applyProfiles bool) (*db.InstanceArgs, error)

ConfigToInstanceDBArgs converts the instance config in the backup config to DB InstanceArgs.

func ConvertFormat

func ConvertFormat(backupConf *config.Config, version uint32) (*config.Config, error)

ConvertFormat converts a backup config's metadata file format between versions. It returns the converted contents and doesn't modify the provided config. In case the requested format is already present it's a noop.

func InstanceTypeToBackupType

func InstanceTypeToBackupType(instanceType api.InstanceType) config.Type

InstanceTypeToBackupType converts instance type to backup type.

func ParseConfigYamlFile

func ParseConfigYamlFile(path string) (*config.Config, error)

ParseConfigYamlFile decodes the YAML file at path specified into a Config.

func TarReader

func TarReader(s *state.State, r io.ReadSeeker, outputPath string) (*tar.Reader, context.CancelFunc, error)

TarReader rewinds backup file handle r and returns new tar reader and process cleanup function.

func UpdateInstanceConfigInPlace

func UpdateInstanceConfigInPlace(c *db.Cluster, b *Info) error

UpdateInstanceConfigInPlace updates the instance's backup index in place.

func ValidateBackupName

func ValidateBackupName(backupName string) (string, error)

ValidateBackupName validates the given backup name. If the name is legal, then the legal name and a nil error are returned. If the name is illegal, then an empty string and an error are returned.

Types

type CommonBackup

type CommonBackup struct {
	// contains filtered or unexported fields
}

CommonBackup represents a common backup.

func (*CommonBackup) CompressionAlgorithm

func (b *CommonBackup) CompressionAlgorithm() string

CompressionAlgorithm returns the compression used for the tarball.

func (*CommonBackup) Name

func (b *CommonBackup) Name() string

Name returns the name of the backup.

func (*CommonBackup) OptimizedStorage

func (b *CommonBackup) OptimizedStorage() bool

OptimizedStorage returns whether the backup is to be performed using optimization supported by the storage driver.

func (*CommonBackup) SetCompressionAlgorithm

func (b *CommonBackup) SetCompressionAlgorithm(compression string)

SetCompressionAlgorithm sets the tarball compression.

type Info

type Info struct {
	Project          string         `json:"-" yaml:"-"` // Project is set during import based on current project.
	Name             string         `json:"name" yaml:"name"`
	Backend          string         `json:"backend" yaml:"backend"`
	Pool             string         `json:"pool" yaml:"pool"`
	Snapshots        []string       `json:"snapshots,omitempty" yaml:"snapshots,omitempty"`
	OptimizedStorage *bool          `json:"optimized,omitempty" yaml:"optimized,omitempty"`               // Optional field to handle older optimized backups that don't have this field.
	OptimizedHeader  *bool          `json:"optimized_header,omitempty" yaml:"optimized_header,omitempty"` // Optional field to handle older optimized backups that don't have this field.
	Type             config.Type    `json:"type,omitempty" yaml:"type,omitempty"`                         // Type of backup.
	Config           *config.Config `json:"config,omitempty" yaml:"config,omitempty"`                     // Equivalent of backup.yaml but embedded in index for quick retrieval.
}

Info represents exported backup information.

func GetInfo

func GetInfo(s *state.State, r io.ReadSeeker, outputPath string) (*Info, error)

GetInfo extracts backup information from a given ReadSeeker.

type Instance

type Instance interface {
	Name() string
	Project() api.Project
	Operation() *operations.Operation
}

Instance represents the backup relevant subset of a LXD instance. This is used rather than instance.Instance to avoid import loops.

type InstanceBackup

type InstanceBackup struct {
	CommonBackup
	// contains filtered or unexported fields
}

InstanceBackup represents an instance backup.

func NewInstanceBackup

func NewInstanceBackup(state *state.State, inst Instance, ID int, name string, creationDate time.Time, expiryDate time.Time, instanceOnly bool, optimizedStorage bool) *InstanceBackup

NewInstanceBackup instantiates a new InstanceBackup struct.

func (*InstanceBackup) Delete

func (b *InstanceBackup) Delete() error

Delete removes an instance backup.

func (*InstanceBackup) Instance

func (b *InstanceBackup) Instance() Instance

Instance returns the instance to be backed up.

func (*InstanceBackup) InstanceOnly

func (b *InstanceBackup) InstanceOnly() bool

InstanceOnly returns whether only the instance itself is to be backed up.

func (*InstanceBackup) Rename

func (b *InstanceBackup) Rename(newName string) error

Rename renames an instance backup.

func (*InstanceBackup) Render

func (b *InstanceBackup) Render() *api.InstanceBackup

Render returns an InstanceBackup struct of the backup.

type VolumeBackup

type VolumeBackup struct {
	CommonBackup
	// contains filtered or unexported fields
}

VolumeBackup represents a custom volume backup.

func NewVolumeBackup

func NewVolumeBackup(state *state.State, projectName, poolName, volumeName string, ID int, name string, creationDate, expiryDate time.Time, volumeOnly, optimizedStorage bool) *VolumeBackup

NewVolumeBackup instantiates a new VolumeBackup struct.

func (*VolumeBackup) Delete

func (b *VolumeBackup) Delete() error

Delete removes a volume backup.

func (*VolumeBackup) Rename

func (b *VolumeBackup) Rename(newName string) error

Rename renames a volume backup.

func (*VolumeBackup) Render

Render returns a VolumeBackup struct of the backup.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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