Feature: Backup & Restore #28
Labels
No labels
area:api
area:core
area:docs
area:infra
area:ux
dependencies
documentation
duplicate
good first issue
help wanted
invalid
question
rust
status:complete
status:partial
status:planned
type:bug
type:design
type:feature
type:infra
type:refactor
type:research
type:ux
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
icub3d/decentcom#28
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Migrated from GitHub issue icub3d/decentcom#28
Original Author: @icub3d
Original Date: 2026-04-15T14:15:57Z
Feature: Backup & Restore
Overview
Backup and restore allows server operators to export all server data as a portable archive and import it on a fresh instance. This is essential for migrating to new hardware, recovering from failure, or cloning a server for testing. The archive format is self-contained and works across storage backends (a backup from a SQLite instance can be restored to a PostgreSQL instance and vice versa).
Background
The storage design doc (
docs/design/storage.md) specifies full backup, incremental backup, and restore as requirements. It raises an open question about a canonical interchange format (JSON + media zip). The server-model doc (docs/design/server-model.md) lists backup and restore as an admin operation accessible via both the client UI and a CLI tool.Depends on:
storage(feature #3),server-config(feature #2), all Phase 1 and Phase 2 features.Requirements
.dcbackupextension) containing JSON metadata and media blobsDesign
API / Interface Changes
REST endpoints:
/api/v1/admin/backup/api/v1/admin/restore/api/v1/admin/backup/statusCLI commands:
decentcom backup --output <path>decentcom restore --input <path>Data Model Changes
No schema changes. The backup archive uses its own internal format:
Archive structure (tar.zst — zstd-compressed tar):
Component Changes
Server (
server/):server/src/backup/— new module directoryserver/src/backup/mod.rs— backup orchestrator: coordinates export/import across all storesserver/src/backup/export.rs— reads from the storage backend, writes JSONL data files and media blobs into a tar.zst archiveserver/src/backup/import.rs— reads from a tar.zst archive, writes to the storage backendserver/src/backup/manifest.rs— manifest struct, serialization, version checkingserver/src/backup/format.rs— constants: magic bytes, version, file paths within the archiveserver/src/routes/admin.rs— add backup and restore endpoints (admin-only, permission check)server/src/bin/backup.rs— CLI entry point for backup/restore (or subcommands of the main binary)server/src/storage/trait.rs— additer_all_*()methods to each store trait for streaming export (e.g.,iter_all_messages() -> impl Stream<Item = Message>)Dependencies:
tarcrate — tar archive creation/readingzstdcrate — zstd compression/decompressionserde_json— JSONL serializationTask List
Phase A: Archive Format and Manifest
server/src/backup/format.rs— define archive structure constants, file extension, magic bytesserver/src/backup/manifest.rs—BackupManifeststruct with version, server name, timestamp, record counts; serialization and validationPhase B: Export
iter_all_*()streaming methods to storage trait for each entity type (users, channels, messages, etc.)iter_all_*()for SQLite backenditer_all_*()for PostgreSQL backend (if available)server/src/backup/export.rs— streaming export: open tar.zst writer, iterate each store, write JSONL files, copy media blobsserver/src/backup/mod.rs—BackupManagerthat coordinates the export processdecentcom backup --output <path>CLI commandPOST /api/v1/admin/backupendpoint with admin permission checkPhase C: Import
server/src/backup/import.rs— streaming import: open tar.zst reader, parse manifest, insert records in dependency order (users first, then channels, then messages, etc.)decentcom restore --input <path>CLI commandPOST /api/v1/admin/restoreendpoint with admin permission checkPhase D: Status and Progress
GET /api/v1/admin/backup/statusendpointTest List
tar -tf backup.dcbackup)Open Questions