mirror of
https://github.com/prosolis/gogobee.git
synced 2026-07-15 00:32:40 +00:00
Phase C1: gate db.Backup() on GOGOBEE_BACKUP_DIR
Audit flagged C1 as "Backup() unwired" — actually adventure_scheduler's dailyReset has been calling it every midnight. The real gap was that Backup() always ran, always to dataPath/backups, with no way for dev environments to opt out. Now: env var unset → no-op + debug log. Env var set → that directory is the destination. Existing scheduler call site unchanged; it cleanly no-ops in dev.
This commit is contained in:
@@ -463,8 +463,16 @@ func CacheSet(key, data string) {
|
||||
|
||||
// Backup creates a consistent snapshot of the database using VACUUM INTO.
|
||||
// Keeps the last 7 daily backups, deleting older ones.
|
||||
//
|
||||
// Gated on the GOGOBEE_BACKUP_DIR env var: when unset, this is a no-op so
|
||||
// dev environments don't accumulate snapshots. When set, that directory is
|
||||
// used as the backup destination.
|
||||
func Backup() error {
|
||||
backupDir := filepath.Join(dataPath, "backups")
|
||||
backupDir := os.Getenv("GOGOBEE_BACKUP_DIR")
|
||||
if backupDir == "" {
|
||||
slog.Debug("backup skipped: GOGOBEE_BACKUP_DIR unset")
|
||||
return nil
|
||||
}
|
||||
if err := os.MkdirAll(backupDir, 0o755); err != nil {
|
||||
return fmt.Errorf("create backup dir: %w", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user