backup

package
v0.0.0-...-ff4e629 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: AGPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const TypeContainer = Type("container")

TypeContainer defines the backup type value for a container.

View Source
const TypeCustom = Type("custom")

TypeCustom defines the backup type value for a custom volume.

View Source
const TypeUnknown = Type("")

TypeUnknown defines the backup type value for unknown backups.

View Source
const TypeVM = Type("virtual-machine")

TypeVM defines the backup type value for a virtual-machine.

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 ParseConfigYamlFile

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

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

func TarReader

func TarReader(r io.ReadSeeker, sysOS *sys.OS, outputPath string) (*tar.Reader, context.CancelFunc, error)

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

func UpdateInstanceConfig

func UpdateInstanceConfig(c *db.Cluster, b Info, mountPath string) error

UpdateInstanceConfig updates the instance's backup.yaml configuration file.

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             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(r io.ReadSeeker, sysOS *sys.OS, 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 Type

type Type string

Type indicates the type of backup.

func InstanceTypeToBackupType

func InstanceTypeToBackupType(instanceType api.InstanceType) Type

InstanceTypeToBackupType converts instance type to backup type.

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) OptimizedStorage

func (b *VolumeBackup) OptimizedStorage() bool

OptimizedStorage returns whether the backup is to be performed using optimization format of the storage driver.

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.

func (*VolumeBackup) VolumeOnly

func (b *VolumeBackup) VolumeOnly() bool

VolumeOnly returns whether only the volume itself is to be backed up.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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