Repository navigation
feat(server): full database backups over REST (#572, first slice) - #584
MPCoreDeveloper wants to merge 7 commits into
Conversation
The server had no backup or restore management surface. DatabaseBackupService flushes the live engine (IDatabase.Flush), copies the database path to <database root>/backups/<db>/<utc>-full/ and writes a manifest, with POST /api/v1/backup/start and GET /api/v1/backup/list (admin only). Full only: no restore, no scheduling, no incremental/differential, no gRPC RPC - all stated in the CHANGELOG Not-in-this-slice section, REST_API and FEATURE_MATRIX so nobody assumes more. Verified against the code first (IDatabase.Flush, DatabaseInstanceConfiguration.DatabasePath, the copy helpers the tenant service already uses). Tests: DatabaseBackupServiceTests (4), server suite 311/0.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
…lder (#572) The new src/SharpCoreDB.Server.Core/Backup/ folder was silently excluded by .gitignore line 262 (Backup*/), so the service never reached the commit and every CI platform failed with CS0234 (no SharpCoreDB.Server.Core.Backup namespace) while the local build passed. Moved to Tenancy/ next to TenantBackupRestoreService, namespace SharpCoreDB.Server.Core.Tenancy, controller and test usings updated, CHANGELOG path corrected. Local: build clean, server suite 311/0.
|
Status: builds and the full server suite pass on all three platforms (the earlier CS0234 was a .gitignore Backup*/ trap - fixed in 9b55e8e by moving the service to Tenancy/). CodeQL and SonarCloud now fail on the new path handling in DatabaseBackupService: the backup directory embeds the requested database name. Not merging a red security check. Fix direction for the next session: derive the backup root from the trusted DatabasePath only and keep the database name out of the filesystem path (manifest field for identification) - then re-run both gates. |
CodeQL cs/path-injection and Sonar S2083 flagged DatabaseBackupService because the backup directory embedded the requested database name. The root is now derived from the configured DatabasePath only and the id is generated (<utc>-full-<random>); the database name lives in the manifest and List filters on it. Sanitize() is gone with it. Docs (REST_API payload + id/path, CHANGELOG) updated to the real layout. Server suite 311/0; backup tests 4/4.
…equest forgery token validation' Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
|
Status: builds and the full server suite pass on all platforms. Two static-analysis findings still block the merge - they are precise and are the next actions. SonarCloud on PR 584:
What is already fixed on the branch:
Server suite 311/0 (backup tests 4/4). |
…from user input' Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
…he path-injection exception (#572) List() measured a cognitive complexity of 18 (>15): the manifest loop now lives in ReadManifests with a Matches helper. sonar-project.properties gains e2/e3 scoped to DatabaseBackupService for S2083/S6549 with the trust-boundary reasoning (path from server configuration, generated target id, requested name validated against the registry and recorded in the manifest) - the same precedent this file already documents for SingleFileStorageProvider. The project-side Sonar setting for the four scoped keys was applied via the API; the multicriteria list setting still has to be applied (the api/settings/set call for that one key answers 400).
…eDeveloper/SharpCoreDB into feat/572-backup-rest-first
|
|
Latest state after 09a6a85 (merge of the Copilot Autofix commits + the S3776 refactor):
One action left, and it needs the parameter form the documented e1 exclusion used (docs/quality/SONAR_AND_COVERAGE.md step 3 - "Project setting sonar.issue.ignore.multicriteria (e1 -> that rule, that file) set through api/settings/set"): set the list to e1,e2,e3 at project level, then push anything to re-run the automatic analysis. The rule keys and resource keys are already stored. Everything else in this PR is verified: backup tests 4/4 and the CHANGELOG/REST_API/FEATURE_MATRIX describe the real layout. |




First slice of #572, built after verifying the existing surface in code (the engine exposes
IDatabase.Flush()and the tenant service already copies a database path; the server had no backup route at all).nnAddedn-DatabaseBackupService: flush the live engine, copyto/backups//-full/, write amanifest.json(id,database,kind,createdUtc,sizeBytes,path). No storage-format access: a directory database copies as a directory, a.scdbas one file.n-POST /api/v1/backup/start?database=andGET /api/v1/backup/list— admin only.n- Docs in the same commit: REST_API (both endpoints with the exact payload), FEATURE_MATRIX, CHANGELOG including aNot in this slicesection.nn**Not in this slice (so #572 stays open)**n- No restore endpoint / restore semantics (new vs existing database).n- No scheduling, retention, incremental or differential backups; no gRPC RPC (a proto change plus a capability-contract entry).n- The copy is a live-path copy after a flush, not a snapshot; concurrent writes are not coordinated.nnTests:DatabaseBackupServiceTests(4). Server suite 311/0 locally.