feat(admin): add H2 database backup & restore management to admin UI (#5528)

# Description of Changes

This PR introduces comprehensive database backup and restore management
for embedded H2 databases directly within the admin UI, along with a
corrected backend condition for H2 detection.

### What was changed
- Fixed `H2SQLCondition` logic so embedded H2 is correctly detected when
custom databases are disabled.
- Updated and expanded unit tests to reflect the corrected H2 enablement
behavior.
- Added a new **Backups & Restore** section to the Admin Database
settings UI.
- Implemented UI features to:
  - Create H2 database backups
  - List available backup files with metadata
  - Download, import, and delete existing backups
- Upload and import `.sql` backup files with a confirmation code safety
step
- Added a new frontend service (`databaseManagementService`) to
encapsulate database management API calls.
- Extended English (en-GB) translations for all new database backup and
restore UI elements.

### Why the change was made
- Embedded H2 is the default database when no custom database is
configured, but this was not consistently reflected in backend
conditions.
- Administrators need a safe, UI-driven way to manage H2 backups without
manual filesystem access.
- The new UI improves operability, safety (confirmation code on import),
and transparency (version and status badges).

<img width="1920" height="1080" alt="image"
src="https://github.com/user-attachments/assets/15869b9c-fa86-4b31-ac9b-8e6424138b73"
/>
<img width="1920" height="1032" alt="image"
src="https://github.com/user-attachments/assets/8668dc07-0384-40f0-91e1-c6973c1ce535"
/>


Closes #5515

---

## Checklist

### General

- [ ] I have read the [Contribution
Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md)
- [ ] I have read the [Stirling-PDF Developer
Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md)
(if applicable)
- [ ] I have read the [How to add new languages to
Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md)
(if applicable)
- [ ] I have performed a self-review of my own code
- [ ] My changes generate no new warnings

### Documentation

- [ ] I have updated relevant docs on [Stirling-PDF's doc
repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/)
(if functionality has heavily changed)
- [ ] I have read the section [Add New Translation
Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md#add-new-translation-tags)
(for new translation tags only)

### Translations (if applicable)

- [ ] I ran
[`scripts/counter_translation.py`](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/docs/counter_translation.md)

### UI Changes (if applicable)

- [ ] Screenshots or videos demonstrating the UI changes are attached
(e.g., as comments or direct attachments in the PR)

### Testing (if applicable)

- [ ] I have tested my changes locally. Refer to the [Testing
Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md#6-testing)
for more details.
This commit is contained in:
Ludy
2026-01-22 19:16:30 +00:00
committed by GitHub
parent df1295059a
commit 56f788957a
5 changed files with 727 additions and 127 deletions
@@ -4759,6 +4759,48 @@ mobileScannerStretchToFitDesc = "Stretch images to fill the entire page. If disa
title = "Database"
description = "Configure custom database connection settings for enterprise deployments."
configuration = "Database Configuration"
backupTitle = "Backups & Restore"
backupDescription = "Manage H2 backups directly from the admin console."
loadError = "Failed to load database backups"
backupCreated = "Backup created successfully"
backupFailed = "Failed to create backup"
deleteTitle = "Delete backup"
deleteConfirm = "Delete this backup? This cannot be undone."
deleteSuccess = "Backup deleted"
deleteFailed = "Failed to delete backup"
deleteConfirmAction = "Delete backup"
downloadFailed = "Failed to download backup"
version = "H2 Version"
embedded = "Embedded H2"
external = "External DB"
h2Only = "Backups are available only for the embedded H2 database."
h2Hint = "Set the database type to H2 and disable custom database to enable backup and restore."
manageBackups = "Manage backups"
refresh = "Refresh"
createBackup = "Create backup"
uploadTitle = "Upload & import"
chooseFile = "Choose a .sql backup file"
importFromUpload = "Import upload"
confirmImportTitle = "Confirm database import"
overwriteWarning = "Warning: This will overwrite the current database."
overwriteWarningBody = "All existing data will be replaced by the uploaded backup. This action cannot be undone."
confirmCodeLabel = "Enter the confirmation code to proceed"
enterCode = "Enter the code shown above"
confirmImport = "Confirm import"
codeMismatch = "Confirmation code does not match"
codeMismatchBody = "Please enter the code exactly as shown to proceed."
selectFile = "Please select a .sql file to import"
importSuccess = "Backup imported successfully"
importFailed = "Failed to import backup"
noBackups = "No backups found yet."
unavailable = "Backup list unavailable for the current database configuration."
fileName = "File"
created = "Created"
size = "Size"
actions = "Actions"
download = "Download"
import = "Import"
delete = "Delete"
[admin.settings.database.enableCustom]
label = "Enable Custom Database"