backup

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package backup implements S3-compatible backup and restore for Luanti server data.

Index

Constants

This section is empty.

Variables

View Source
var ErrMissingCredentials = errors.New(
	"LUCTL_S3_ACCESS_KEY and LUCTL_S3_SECRET_KEY must be set",
)

ErrMissingCredentials is returned when S3 credential env vars are not set.

Functions

func Create

func Create(ctx context.Context, client *s3.Client, cfg project.BackupConfig, sources []string) (string, error)

Create archives sources as a tar.gz, uploads it to S3, and returns the object key. sources is the list of filesystem paths to include (world dir + conf file).

func DownloadToWriter

func DownloadToWriter(ctx context.Context, client *s3.Client, bucket, key string, w io.Writer) error

DownloadToWriter downloads a backup object and writes it to w. Exposed for restore-to-stdout use cases.

func FormatSize

func FormatSize(b int64) string

FormatSize returns a human-readable size string (KB / MB / GB).

func LatestName

func LatestName(ctx context.Context, client *s3.Client, cfg project.BackupConfig) (string, error)

LatestName returns the name (without prefix) of the most recently modified backup, or an error if no backups exist.

func NewS3Client

func NewS3Client(cfg project.BackupConfig) (*s3.Client, error)

NewS3Client constructs an S3 client from the project backup config and env vars. Credentials are read from LUCTL_S3_ACCESS_KEY / LUCTL_S3_SECRET_KEY only.

func Restore

func Restore(ctx context.Context, client *s3.Client, cfg project.BackupConfig, name, destDir string) error

Restore downloads the backup identified by name (without prefix) and extracts it to destDir.

func ValidateConfig

func ValidateConfig(cfg project.BackupConfig) error

ValidateConfig checks that all required backup fields are present.

Types

type Entry

type Entry struct {
	Name         string
	Key          string
	LastModified time.Time
	SizeBytes    int64
}

Entry describes a single backup object in S3.

func List

func List(ctx context.Context, client *s3.Client, cfg project.BackupConfig) ([]Entry, error)

List returns all backup objects stored under the configured prefix.

Jump to

Keyboard shortcuts

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