exporter

package
v0.0.0-...-dae269f Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2023 License: AGPL-3.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ReportPlainPath   = "README.txt"
	ReportMachinePath = "report.json"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Backup

type Backup struct {
	Description BackupDescription

	// Start and End Time of the backup
	StartTime time.Time
	EndTime   time.Time

	// various error states, which are ignored when creating the snapshot
	ErrPanic interface{}

	// errors for the various components
	ComponentErrors map[string]error

	// TODO: Make this proper
	ConfigFileErr error

	// Snapshots containing instances
	InstanceListErr   error
	InstanceSnapshots []Snapshot

	// List of files included
	WithManifest
}

Backup describes a backup

func (*Backup) LogEntry

func (backup *Backup) LogEntry() models.Export

func (Backup) ReportMachine

func (backup Backup) ReportMachine(w io.Writer) error

func (Backup) ReportPlain

func (backup Backup) ReportPlain(w io.Writer) error

Report formats a report for this backup, and writes it into Writer.

func (Backup) String

func (backup Backup) String() string

Strings turns this backup into a string for the BackupReport.

type BackupDescription

type BackupDescription struct {
	Dest string // Destination path

	ConcurrentSnapshots int // maximum number of concurrent snapshots
}

BackupDescription provides a description for a backup

type Bookkeeping

type Bookkeeping struct {
	component.Base
}

func (*Bookkeeping) Snapshot

func (*Bookkeeping) Snapshot(wisski models.Instance, scontext *component.StagingContext) error

Snapshot creates a snapshot of this instance

func (Bookkeeping) SnapshotName

func (Bookkeeping) SnapshotName() string

SnapshotName returns a new name to be used as an argument for path.

func (Bookkeeping) SnapshotNeedsRunning

func (Bookkeeping) SnapshotNeedsRunning() bool

SnapshotNeedsRunning returns if this Snapshotable requires a running instance.

type Config

type Config struct {
	component.Base
}

Config implements backing up configuration

func (*Config) Backup

func (control *Config) Backup(scontext *component.StagingContext) error

func (*Config) BackupName

func (*Config) BackupName() string

type ExportTask

type ExportTask struct {
	// Dest is the destination path to write the backup to.
	// When empty, this is created automatically in the staging or archive directory.
	Dest string

	// By default, a .tar.gz file is generated.
	// To generated an unpacked directory, set [StagingOnly] to true.
	StagingOnly bool

	// Parts explicitly lists parts to include inside the snapshot.
	// If non-empty, only include parts with the specified names.
	// if empty, include all possible components.
	Parts []string

	// Instance is the instance to generate a snapshot of.
	// To generate a backup, leave this to be nil.
	Instance *wisski.WissKI

	// BackupDescriptions and SnapshotDescriptions further specitfy options for the export.
	// The Dest parameter is ignored, and updated automatically.
	BackupDescription   BackupDescription
	SnapshotDescription SnapshotDescription
}

ExportTask describes a task that makes either a Backup or a Snapshot. See Exporter.MakeExport

type Exporter

type Exporter struct {
	component.Base
	Dependencies struct {
		SQL            *sql.SQL
		Instances      *instances.Instances
		ExporterLogger *logger.Logger

		Snapshotable []component.Snapshotable
		Backupable   []component.Backupable
	}
}

Exporter manages snapshots and backups

func (*Exporter) ArchivePath

func (dis *Exporter) ArchivePath() string

ArchivePath returns the path to the directory containing all exported archives. Use NewSnapshotArchivePath to generate a path to a new archive in this directory.

func (*Exporter) MakeExport

func (exporter *Exporter) MakeExport(ctx context.Context, progress io.Writer, task ExportTask) (err error)

MakeExport performs an export task as described by flags. Output is directed to the provided io.

func (*Exporter) NewArchivePath

func (dis *Exporter) NewArchivePath(prefix string) (path string)

NewArchivePath returns the path to a new archive with the provided prefix. The path is guaranteed to not exist.

func (*Exporter) NewBackup

func (exporter *Exporter) NewBackup(ctx context.Context, progress io.Writer, description BackupDescription) (backup Backup)

New create a new Backup

func (*Exporter) NewSnapshot

func (exporter *Exporter) NewSnapshot(ctx context.Context, instance *wisski.WissKI, progress io.Writer, desc SnapshotDescription) (snapshot Snapshot)

Snapshot creates a new snapshot of this instance into dest

func (*Exporter) NewStagingDir

func (dis *Exporter) NewStagingDir(prefix string) (path string, err error)

NewStagingDir returns the path to a new snapshot directory. The directory is guaranteed to have been freshly created.

func (*Exporter) Parts

func (exporter *Exporter) Parts() []string

Parts lists all available snapshot parts

func (*Exporter) Path

func (dis *Exporter) Path() string

Path returns the path that contains all snapshot related data.

func (*Exporter) PruneExports

func (exporter *Exporter) PruneExports(ctx context.Context, progress io.Writer) error

Prune prunes all old exports

func (*Exporter) ShouldPrune

func (exporter *Exporter) ShouldPrune(modtime time.Time) bool

ShouldPrune determines if a file with the provided modification time should be removed from the export log.

func (*Exporter) StagingPath

func (dis *Exporter) StagingPath() string

StagingPath returns the path to the directory containing a temporary staging area for snapshots. Use NewSnapshotStagingDir to generate a new staging area.

type Filesystem

type Filesystem struct {
	component.Base
}

Filesystem implements snapshotting an instnace filesystem

func (*Filesystem) Snapshot

func (*Filesystem) Snapshot(wisski models.Instance, context *component.StagingContext) error

Snapshot creates a snapshot of this instance

func (Filesystem) SnapshotName

func (Filesystem) SnapshotName() string

SnapshotName returns a new name to be used as an argument for path.

func (Filesystem) SnapshotNeedsRunning

func (Filesystem) SnapshotNeedsRunning() bool

SnapshotNeedsRunning returns if this Snapshotable requires a running instance.

type Pathbuilders

type Pathbuilders struct {
	component.Base
	Dependencies struct {
		Instances *instances.Instances
	}
}

func (*Pathbuilders) Snapshot

func (pbs *Pathbuilders) Snapshot(wisski models.Instance, scontext *component.StagingContext) error

func (Pathbuilders) SnapshotName

func (Pathbuilders) SnapshotName() string

func (Pathbuilders) SnapshotNeedsRunning

func (Pathbuilders) SnapshotNeedsRunning() bool

type Snapshot

type Snapshot struct {
	Description SnapshotDescription
	Instance    models.Instance

	// Start and End Time of the snapshot
	StartTime time.Time
	EndTime   time.Time

	// Generic Panic that may have occured
	ErrPanic interface{}
	ErrStart error
	ErrStop  error

	// Errors holds errors for each component
	Errors map[string]error

	// Logs contains logfiles for each component
	Logs map[string]string

	// List of files included
	WithManifest
	// contains filtered or unexported fields
}

Snapshot represents the result of generating a snapshot

func (*Snapshot) LogEntry

func (snapshot *Snapshot) LogEntry() models.Export

func (Snapshot) ReportMachine

func (snapshot Snapshot) ReportMachine(w io.Writer) error

func (Snapshot) ReportPlain

func (snapshot Snapshot) ReportPlain(w io.Writer) error

func (Snapshot) String

func (snapshot Snapshot) String() string

type SnapshotDescription

type SnapshotDescription struct {
	Dest      string // destination path
	Keepalive bool   // should we keep the instance alive while making the snapshot?

	Parts []string // SnapshotName()s of the components to include.
}

SnapshotDescription is a description for a snapshot

type WithManifest

type WithManifest struct {
	Manifest []string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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