Add Export/Import backup functionality to the admin panel Setup page#715
Draft
Add Export/Import backup functionality to the admin panel Setup page#715
Conversation
Co-authored-by: sven-n <5238610+sven-n@users.noreply.github.com> Agent-Logs-Url: https://github.com/MUnique/OpenMU/sessions/fa43bd29-5da9-403d-81e2-28502a6c8273
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 implementationInMemoryBackupService(Persistence.InMemory) — no-op stubExport (
CreateBackupAsync)Exports all top-level aggregate roots to individual JSON files packed into a ZIP:
GameConfiguration_{id}.json— viaGameConfigurationJsonObjectLoaderChatServerDefinition_{id}.json,ConnectServerDefinition_{id}.json,GameServerDefinition_{id}.json— via EFIncludequeriesAccount_{id}.json— viaAccountJsonObjectLoaderA single shared
IdReferenceHandleris used across all serializations so cross-type references (e.g.,ConnectServerDefinition.Client → GameClientDefinition) are written as$refinstead of being inlined repeatedly.Restore (
RestoreBackupAsync)Files are processed in dependency order (GameConfiguration first). A shared
IdReferenceHandleraccumulates deserialized objects so$refvalues resolve across files. Objects are reconstructed into EF model types viaIContext.CreateNew(baseType)with a reflection-based property/collection walker that deduplicates by ID via aDictionary<Guid, object>.Supporting changes
JsonObjectSerializer.SerializeAsyncgains an overload accepting an externalReferenceHandlerto share reference state across multiple serializationsExtendedTypes.Custom.csaddsIConvertibleTo<BasicModel.ChatServerDefinition>andIConvertibleTo<BasicModel.GameServerDefinition>(mirrors existingGameConfiguration/Accountpattern)BackupController(/admin/backup) —GETstreams the ZIP download;POSTcallsIMigratableDatabaseContextProvider.ReCreateDatabaseAsync()thenRestoreBackupAsyncInputFile-based Import section with in-progress/success/error feedbackIBackupServiceregistered in bothStartup/Program.cs(conditionally EF vs InMemory) andDapr/Common/Extensions.csOriginal prompt
💡 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.