Documentation
¶
Overview ¶
Package backup implements S3-compatible backup and restore for Luanti server data.
Index ¶
- Variables
- func Create(ctx context.Context, client *s3.Client, cfg project.BackupConfig, ...) (string, error)
- func DownloadToWriter(ctx context.Context, client *s3.Client, bucket, key string, w io.Writer) error
- func FormatSize(b int64) string
- func LatestName(ctx context.Context, client *s3.Client, cfg project.BackupConfig) (string, error)
- func NewS3Client(cfg project.BackupConfig) (*s3.Client, error)
- func Restore(ctx context.Context, client *s3.Client, cfg project.BackupConfig, ...) error
- func ValidateConfig(cfg project.BackupConfig) error
- type Entry
Constants ¶
This section is empty.
Variables ¶
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 ¶
FormatSize returns a human-readable size string (KB / MB / GB).
func LatestName ¶
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.