# State Export/Imort

LagomChain can dump the entire application state to a JSON file. This, besides upgrades, can be useful for manual analysis of the state at a given height.

### Export State[​](broken://pages/kr3FCey94LsN2JcUc44r) <a href="#export-state" id="export-state"></a>

Export state with:

```
lagomd export > new_genesis.json
```

You can also export state from a particular height (at the end of processing the block of that height):

```
lagomd export --height [height] > new_genesis.json
```

If you plan to start a new network for 0 height (i.e genesis) from the exported state, export with the `--for-zero-height` flag:

```
lagomd export --height [height] --for-zero-height > new_genesis.json
```

### Manually Migrate State[​](broken://pages/kr3FCey94LsN2JcUc44r) <a href="#manually-migrate-state" id="manually-migrate-state"></a>

If you want to migrate state manually, e.g. for local testing purpose. Note that for regular chain upgrades, a manual state migration is not required.

After exporting your state into a json file, you can replace the old `genesis.json` with `new_genesis.json`.

```
cp -f genesis.json new_genesis.json
mv new_genesis.json genesis.json
```

At this point, you might want to run a script to update the exported genesis into a genesis state that is compatible with your new version.

You can use the `migrate` command to migrate from a given version to the next one (eg: `v0.X.X` to `v1.X.X`):

```
lagomd migrate TARGET_VERSION GENESIS_FILE --chain-id=<new_chain_id> --genesis-time=<yyyy-mm-ddThh:mm:ssZ>
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.lagomchain.com/concepts/state-export-imort.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
