Documentation
¶
Overview ¶
Package backup creates downloadable backup archives and stages uploaded archives for restoration on the next process startup.
Index ¶
Constants ¶
const (
MaxArchiveSize int64 = 4 << 30 // 4 GiB
)
Variables ¶
This section is empty.
Functions ¶
func DownloadBackup ¶
DownloadBackup 使用白名单打包 ./data 及数据库文件为 zip 并下载, 同时归档到 ./data/backup/ 确保 Docker 挂载后备份文件可持久化。
归档文件由前端后续统一管理,服务端只负责生成并保存。
func FinalizeUploadedRestore ¶
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 ¶
SaveUploadedBackup validates a Komari backup and stages it for restoration during the next process startup.
func ValidateArchive ¶
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.