Restore Command
The restore command reads entity JSON files from a local dump directory and creates or updates them in a Qelos instance. It is the counterpart of dump and is designed for cross-environment migration.
Key feature: identity resolution
When entity files contain usernames or workspace names instead of ObjectIDs (produced by dump blueprints), the restore command automatically resolves them:
- Looks up the user by username in the target environment.
- If not found and
users.jsonexists in the dump directory, creates the user from the dump data. - Replaces the username with the new user's
_id. - Same logic applies for workspace names using
workspaces.json.
This means you can dump from production and restore to staging without manually mapping IDs.
restore blueprints
Usage
bash
qelos restore blueprints [blueprints] [options]Arguments
| Argument | Description | Default |
|---|---|---|
blueprints | Blueprint identifiers to restore (comma-separated) or all. | all |
Options
| Option | Description | Default |
|---|---|---|
--include | Only restore files whose name includes this value. Comma-separated for multiple patterns. | — |
--exclude | Skip files whose name includes this value. Comma-separated for multiple patterns. | — |
--override | JSON object that is deep-merged into every entity before restoring. | — |
--replace | Replace local JSON files with API response data after each restore. | false |
--path | Base directory where dump data is stored. | ./dump |
What the command does
- Authenticates with the target Qelos instance.
- Initializes identity resolution — fetches users/workspaces from the target env and loads local
users.json/workspaces.json. - Resolves blueprints — if
all, discovers blueprint names from subdirectories in<path>/entities/. - Reads JSON files from each blueprint directory, applying
--include/--excludefilters. - Resolves identities — for each entity, replaces usernames/workspace names with ObjectIDs (creating missing users/workspaces as needed).
- Applies the override (if provided) via recursive deep merge.
- Creates or updates each entity.
- Replaces local files (when
--replaceis set) with API response data.
Examples
Full migration workflow
bash
# On source environment
export QELOS_URL=https://prod.example.com
qelos dump users
qelos dump workspaces
qelos dump blueprints
# On target environment
export QELOS_URL=https://staging.example.com
qelos restore blueprintsRestore specific blueprints
bash
qelos restore blueprints user,orderRestore with override
bash
qelos restore blueprints order \
--override '{"metadata":{"migrated":true}}'Selective file restore
bash
# Only page-1 files
qelos restore blueprints order --include page-1
# Skip certain groups
qelos restore blueprints order --exclude cancelled,draftRestore and sync back server data
bash
qelos restore blueprints order --replaceCustom dump path
bash
qelos restore blueprints all --path ./backupIdentity resolution in detail
Given an entity file with:
json
{
"user": "john.doe",
"workspace": "My Workspace",
"metadata": { "name": "Order A" }
}The restore command will:
- Look up
john.doeby username in the target environment. - If not found, check
users.jsonfor a user withusername: "john.doe"and create them. - Replace
"john.doe"with the user's_id(e.g."67a2b3c4d5e6..."). - Same for
"My Workspace"→ look up or create → replace with_id. - The entity sent to the API will have valid ObjectIDs for the target environment.
Related Commands
qelos dump— Dump entities, users, and workspaces from a Qelos instanceqelos blueprints generate— Generate blueprint definitions from a MongoDB databaseqelos push— Push blueprint definitions, components, and other resource types
