Skip to content

Add Export/Import backup functionality to the admin panel Setup page#715

Draft
Copilot wants to merge 2 commits intomasterfrom
copilot/add-backup-restore-functionality
Draft

Add Export/Import backup functionality to the admin panel Setup page#715
Copilot wants to merge 2 commits intomasterfrom
copilot/add-backup-restore-functionality

Conversation

Copy link
Contributor

Copilot AI commented Mar 20, 2026

The admin panel lacked any way to backup or restore game configuration and account data. This adds a ZIP-based export/import on the Setup page, using the existing stable JSON serializer (circular-reference-safe via IdReferenceHandler).

New Abstractions

  • IBackupService (Persistence) — CreateBackupAsync(Stream) / RestoreBackupAsync(Stream)
  • EfBackupService (Persistence.EntityFramework) — full EF implementation
  • InMemoryBackupService (Persistence.InMemory) — no-op stub

Export (CreateBackupAsync)

Exports all top-level aggregate roots to individual JSON files packed into a ZIP:

  • GameConfiguration_{id}.json — via GameConfigurationJsonObjectLoader
  • ChatServerDefinition_{id}.json, ConnectServerDefinition_{id}.json, GameServerDefinition_{id}.json — via EF Include queries
  • Account_{id}.json — via AccountJsonObjectLoader

A single shared IdReferenceHandler is used across all serializations so cross-type references (e.g., ConnectServerDefinition.Client → GameClientDefinition) are written as $ref instead of being inlined repeatedly.

Restore (RestoreBackupAsync)

Files are processed in dependency order (GameConfiguration first). A shared IdReferenceHandler accumulates deserialized objects so $ref values resolve across files. Objects are reconstructed into EF model types via IContext.CreateNew(baseType) with a reflection-based property/collection walker that deduplicates by ID via a Dictionary<Guid, object>.

Supporting changes

  • JsonObjectSerializer.SerializeAsync gains an overload accepting an external ReferenceHandler to share reference state across multiple serializations
  • ExtendedTypes.Custom.cs adds IConvertibleTo<BasicModel.ChatServerDefinition> and IConvertibleTo<BasicModel.GameServerDefinition> (mirrors existing GameConfiguration/Account pattern)
  • BackupController (/admin/backup) — GET streams the ZIP download; POST calls IMigratableDatabaseContextProvider.ReCreateDatabaseAsync() then RestoreBackupAsync
  • Setup page gets an Export link and an InputFile-based Import section with in-progress/success/error feedback
  • IBackupService registered in both Startup/Program.cs (conditionally EF vs InMemory) and Dapr/Common/Extensions.cs
Original prompt

This section details on the original issue you should resolve

<issue_title>Backup/Restore over the admin panel</issue_title>
<issue_description>Is your feature request related to a problem? Please describe.
For backup and debugging purposes it would be nice to have a simple way to backup and restore the configuration and selected accounts. Not only GameConfiguration needs to be considered, but all other configuration types (not in its composition root), too.

Describe the solution you'd like
The admin panel could get a Export and Import functionality on the Setup page of the admin panel. As data format, we could use jsons in zip archive, since we have a stable json serializer for that which supports circular references and other nasty stuff. The single configuration files and account files could be packed into one zip archive.

See also JsonDownloadController.
</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Add backup and restore functionality over the admin panel Add Export/Import backup functionality to the admin panel Setup page Mar 20, 2026
Copilot AI requested a review from sven-n March 20, 2026 23:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Backup/Restore over the admin panel

2 participants