471cfdd161
- 1 - Add: Gitea now creates timestamped database backup bundles under `[backup].PATH`, exposes the backup schedule in the installer, and surfaces the `database_backup` cron task in admin monitoring. - 2 - Add: installed instances now use `.gitea-installed` and `.gitea-recovery.ini` to enter email-gated recovery instead of falling back to public install mode when configuration or database access is broken. - 3 - Mod: the installer recovery flow now covers backup-bundle restore, bundled or manual `app.ini` reuse, uploaded SQL/GZ database restores, and repository-filesystem recovery with source-specific validation, confirmations, and preserved launcher state. - 4 - Fix: recovery now restores bundled `app.ini` snapshots when needed, discovers backup bundles from both the active backup path and persisted `.gitea-recovery.ini` path, and preserves SMTP and other rebuilt settings correctly when `app.ini` is missing or incomplete. - 5 - Fix: recovery validation and restore handling now accept either a selected backup bundle or an uploaded SQL/GZ dump, keep sensitive secrets and existing `LFS_JWT_SECRET` when appropriate, clear SQLite restore targets before import, and complete the post-install handoff without redirect loops. - 6 - Mod: fresh installs now default recovery email authorization to enabled with first-admin fallback, and the install/recovery UI, styling, and EN/RO wording were refined to match the final launcher behavior. Co-Authored-By: petru @ codex (GPT-5) <codex@openai.com> (cherry picked from commit 9879caf2292691b0cb521d12e6fee924b066bae2)
46 lines
983 B
Go
46 lines
983 B
Go
// Copyright 2026 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package setting
|
|
|
|
import (
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
// start edit/add - by petru @ codex
|
|
func TestLoadBackupFrom(t *testing.T) {
|
|
oldAppWorkPath := AppWorkPath
|
|
oldAppDataPath := AppDataPath
|
|
oldBackup := Backup
|
|
defer func() {
|
|
AppWorkPath = oldAppWorkPath
|
|
AppDataPath = oldAppDataPath
|
|
Backup = oldBackup
|
|
}()
|
|
|
|
AppWorkPath = "/srv/gitea"
|
|
AppDataPath = "data"
|
|
|
|
cfg, err := NewConfigProviderFromData(`
|
|
[backup]
|
|
PATH = backups/custom-db
|
|
RETENTION_COUNT = -4
|
|
COMPRESS = false
|
|
INCLUDE_APP_INI_SNAPSHOT = false
|
|
`)
|
|
require.NoError(t, err)
|
|
|
|
loadBackupFrom(cfg)
|
|
|
|
assert.Equal(t, filepath.Join(AppWorkPath, "backups", "custom-db"), Backup.Path)
|
|
assert.Equal(t, 0, Backup.RetentionCount)
|
|
assert.False(t, Backup.Compress)
|
|
assert.False(t, Backup.IncludeAppINISnapshot)
|
|
}
|
|
|
|
// end edit/add - by petru @ codex
|