backup

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2026 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Overview

Package backup provides VolumeSnapshot backup functionality with RCON hooks.

Index

Constants

View Source
const (
	// LabelServerName is the label key for the PaperMCServer name.
	LabelServerName = "mc.k8s.lex.la/server-name"

	// LabelTrigger is the label key for what triggered the backup.
	LabelTrigger = "mc.k8s.lex.la/backup-trigger"

	// LabelManagedBy is the label key indicating the managing controller.
	LabelManagedBy = "app.kubernetes.io/managed-by"
)
View Source
const SaveFlushDelay = 2 * time.Second

SaveFlushDelay is the time to wait after save-all for data to flush to disk.

Variables

This section is empty.

Functions

func PostSnapshotHook

func PostSnapshotHook(_ context.Context, rcon RCONCommander) error

PostSnapshotHook re-enables auto-save after a snapshot is taken. This function always attempts to send save-on, even if the parent context is cancelled. Leaving auto-save disabled would cause data loss.

func PreSnapshotHook

func PreSnapshotHook(ctx context.Context, rcon RCONCommander) error

PreSnapshotHook prepares the Minecraft server for a consistent snapshot. It sends save-all to flush all data to disk, waits for the flush, then sends save-off to disable auto-save during the snapshot.

Types

type RCONCommander

type RCONCommander interface {
	SendCommand(ctx context.Context, command string) (string, error)
}

RCONCommander is the interface for sending RCON commands. This is a subset of the full RCON client interface, used by backup hooks.

type SnapshotRequest

type SnapshotRequest struct {
	Namespace               string
	PVCName                 string
	ServerName              string
	VolumeSnapshotClassName string
	Trigger                 string

	// Timestamp for the snapshot name. If zero, time.Now() is used.
	Timestamp time.Time

	// OwnerReferences to set on the VolumeSnapshot for cascade deletion.
	OwnerReferences []metav1.OwnerReference
}

SnapshotRequest contains the parameters for creating a VolumeSnapshot.

type Snapshotter

type Snapshotter interface {
	CreateSnapshot(ctx context.Context, req SnapshotRequest) (string, error)
	ListSnapshots(ctx context.Context, namespace, serverName string) ([]volumesnapshotv1.VolumeSnapshot, error)
	DeleteOldSnapshots(ctx context.Context, namespace, serverName string, maxCount int) (int, error)
}

Snapshotter creates and manages VolumeSnapshots.

type VolumeSnapshotSnapshotter

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

VolumeSnapshotSnapshotter implements Snapshotter using the Kubernetes VolumeSnapshot API.

func NewSnapshotter

func NewSnapshotter(c client.Client) *VolumeSnapshotSnapshotter

NewSnapshotter creates a new VolumeSnapshotSnapshotter.

func (*VolumeSnapshotSnapshotter) CreateSnapshot

func (s *VolumeSnapshotSnapshotter) CreateSnapshot(ctx context.Context, req SnapshotRequest) (string, error)

CreateSnapshot creates a VolumeSnapshot from the specified PVC.

func (*VolumeSnapshotSnapshotter) DeleteOldSnapshots

func (s *VolumeSnapshotSnapshotter) DeleteOldSnapshots(
	ctx context.Context,
	namespace, serverName string,
	maxCount int,
) (int, error)

DeleteOldSnapshots deletes the oldest snapshots when the count exceeds maxCount. Returns the number of snapshots deleted.

func (*VolumeSnapshotSnapshotter) ListSnapshots

func (s *VolumeSnapshotSnapshotter) ListSnapshots(
	ctx context.Context,
	namespace, serverName string,
) ([]volumesnapshotv1.VolumeSnapshot, error)

ListSnapshots returns all VolumeSnapshots managed by this operator for the given server.

Jump to

Keyboard shortcuts

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