backup

package
v1.1.0-beta.2 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package backup creates downloadable backup archives and stages uploaded archives for restoration on the next process startup.

Index

Constants

View Source
const (
	MaxArchiveSize int64 = 4 << 30 // 4 GiB

)

Variables

This section is empty.

Functions

func DownloadBackup

func DownloadBackup(c *gin.Context)

DownloadBackup 使用白名单打包 ./data 及数据库文件为 zip 并下载, 同时归档到 ./data/backup/ 确保 Docker 挂载后备份文件可持久化。

归档文件由前端后续统一管理,服务端只负责生成并保存。

func FinalizeUploadedRestore

func FinalizeUploadedRestore(archivePath, filename string) error

FinalizeUploadedRestore stages an already-merged backup archive at archivePath and schedules the process to restart so the staged backup applies during the next startup.

func RegisterRoutes

func RegisterRoutes(g *gin.RouterGroup)

RegisterRoutes binds the backup feature's admin routes under g (typically /api/admin). Restoring from a backup goes through the shared chunked-upload endpoint (see internal/transport/router's upload wiring), not through here.

func SaveUploadedBackup

func SaveUploadedBackup(file io.Reader, filename string) error

SaveUploadedBackup validates a Komari backup and stages it for restoration during the next process startup.

func ValidateArchive

func ValidateArchive(path string) error

ValidateArchive checks the backup marker and bounds archive expansion before the startup restore path extracts it into data/.

Types

type RestoreLock

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

RestoreLock serializes staging a backup until the caller releases it. A successful restore must hold this lock until the process restarts so a second request cannot replace backup.zip in the meantime.

func AcquireRestoreLock

func AcquireRestoreLock() (*RestoreLock, error)

func (*RestoreLock) Release

func (l *RestoreLock) Release()

func (*RestoreLock) SaveUploadedBackup

func (l *RestoreLock) SaveUploadedBackup(file io.Reader, filename string) error

SaveUploadedBackup stages a backup while the caller holds the restore lock.

Jump to

Keyboard shortcuts

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