Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var (
DB *gorm.DB
)
Functions ¶
func CheckError ¶
func CheckError(err error)
CheckError inspects a GORM error for SQLite corruption or a closed database connection. Delegates to the watchdog package for auto-repair.
func Get ¶
Get returns the current database connection. Use this instead of storing a *gorm.DB reference so that watchdog reconnects propagate automatically.
func Reinit ¶
func Reinit() error
Reinit closes the current connection and reopens the database. Called after restoring from backup to pick up the new DB file.
func RestoreFromBackup ¶
func RestoreFromBackup() error
RestoreFromBackup is the package-level function called by the watchdog.
Types ¶
type BackupManager ¶
type BackupManager struct {
// contains filtered or unexported fields
}
BackupManager performs two tiers of online backups using SQLite's Backup API:
- Rotating snapshots: frequent (default 5m), 3 slots — for crash/corruption recovery.
- Daily archives: one per day, kept for 30 days — for real data-loss recovery.
func (*BackupManager) Restore ¶
func (bm *BackupManager) Restore() error
Restore finds the newest valid backup across both tiers and replaces the main database.
func (*BackupManager) Start ¶
func (bm *BackupManager) Start(ctx context.Context)
Start runs the periodic backup loop.