# Exporting and Importing data

**URL:** <https://community.openfn.org/t/exporting-and-importing-data/342>\
**Category:** Self-Hosting\
**Created:** [July 18, 2023, 12:09pm UTC](https://community.openfn.org/t/exporting-and-importing-data/342 "2023-07-18T12:09:07Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![mahaomolise92](https://community.openfn.org/user_avatar/community.openfn.org/mahaomolise92/32/135_2.png) [@mahaomolise92](https://community.openfn.org/u/mahaomolise92)\
**Post date:** [July 18, 2023, 12:09pm UTC](https://community.openfn.org/t/exporting-and-importing-data/342/1 "2023-07-18T12:09:07Z")

</div>

How do I export data from openfn lightning instance and import it to another instance.

---

<div class="post-metadata">

**Author:** ![zacck](https://community.openfn.org/letter_avatar_proxy/v4/letter/z/a9adbd/32.png) [@zacck](https://community.openfn.org/u/zacck)\
**Post date:** [July 18, 2023, 2:16pm UTC](https://community.openfn.org/t/exporting-and-importing-data/342/2 "2023-07-18T14:16:55Z")

</div>

Hi Mahao, I am working on this feature set at the moment so I believe I may be in a position to help.

You can achieve this by using the `openfn cli` it provides 2 commands that will do this for you.

1.openfn pull - this command will at pull the current project spec and state from the instance and will provide you with `project.yaml` and `state.json`

2.openfn deploy - this command deploys a `project.yaml` spec to an instance

Let me know how I can assist you further I am actively working on this feature at the moment and I am on standby to see how I can help

---

<div class="post-metadata">

**Author:** ![mahaomolise92](https://community.openfn.org/user_avatar/community.openfn.org/mahaomolise92/32/135_2.png) [@mahaomolise92](https://community.openfn.org/u/mahaomolise92)\
**Post date:** [July 18, 2023, 3:34pm UTC](https://community.openfn.org/t/exporting-and-importing-data/342/3 "2023-07-18T15:34:26Z")

</div>

Hi Zacck,  
Thanks for this, I will try it out and get back to you if I need more assistance

---

<div class="post-metadata">

**Author:** ![mahaomolise92](https://community.openfn.org/user_avatar/community.openfn.org/mahaomolise92/32/135_2.png) [@mahaomolise92](https://community.openfn.org/u/mahaomolise92)\
**Post date:** [July 19, 2023, 3:25pm UTC](https://community.openfn.org/t/exporting-and-importing-data/342/5 "2023-07-19T15:25:52Z")

</div>

this is What I get when I run pull command

openfn pull  
[CLI] ♦ Downloading project yaml and state from instance

[CLI] ✘ Command failed!  
[CLI] ✘ Error: Failed to fetch project undefined: Bad Request  
at getProject (file:///home/mahao/.nvm/versions/node/v19.4.0/lib/node\_modules/@openfn/cli/node\_modules/@openfn/deploy/dist/index.js:386:13)  
at process.processTicksAndRejections (node:internal/process/task\_queues:95:5)  
at async pullHandler (file:///home/mahao/.nvm/versions/node/v19.4.0/lib/node\_modules/@openfn/cli/dist/process/runner.js:1049:33)  
at async parse (file:///home/mahao/.nvm/versions/node/v19.4.0/lib/node\_modules/@openfn/cli/dist/process/runner.js:1297:20)

---

<div class="post-metadata">

**Author:** ![mahaomolise92](https://community.openfn.org/user_avatar/community.openfn.org/mahaomolise92/32/135_2.png) [@mahaomolise92](https://community.openfn.org/u/mahaomolise92)\
**Post date:** [July 19, 2023, 3:27pm UTC](https://community.openfn.org/t/exporting-and-importing-data/342/6 "2023-07-19T15:27:51Z")

</div>

I have apiKey and endpoint in my .config file

---

<div class="post-metadata">

**Author:** ![zacck](https://community.openfn.org/letter_avatar_proxy/v4/letter/z/a9adbd/32.png) [@zacck](https://community.openfn.org/u/zacck)\
**Post date:** [July 26, 2023, 11:49am UTC](https://community.openfn.org/t/exporting-and-importing-data/342/7 "2023-07-26T11:49:22Z")

</div>

Hey @mahaomolise92 would you like to schedule some time to meet and run you through this, I am looking at your issue I apologize I’ve been swamped and held up

---

<div class="post-metadata">

**Author:** ![mahaomolise92](https://community.openfn.org/user_avatar/community.openfn.org/mahaomolise92/32/135_2.png) [@mahaomolise92](https://community.openfn.org/u/mahaomolise92)\
**Post date:** [July 26, 2023, 3:12pm UTC](https://community.openfn.org/t/exporting-and-importing-data/342/8 "2023-07-26T15:12:12Z")

</div>

Hello Zacck, kindly share the time when you will be available to take me through this.

kind regards  
Mahao

---

<div class="post-metadata">

**Author:** ![mahaomolise92](https://community.openfn.org/user_avatar/community.openfn.org/mahaomolise92/32/135_2.png) [@mahaomolise92](https://community.openfn.org/u/mahaomolise92)\
**Post date:** [August 2, 2023, 5:19pm UTC](https://community.openfn.org/t/exporting-and-importing-data/342/9 "2023-08-02T17:19:26Z")

</div>

Hello Zacck when will you be available

---

<div class="post-metadata">

**Author:** ![taylordowns2000](https://community.openfn.org/user_avatar/community.openfn.org/taylordowns2000/32/165_2.png) [@taylordowns2000](https://community.openfn.org/u/taylordowns2000)\
**Post date:** [August 2, 2023, 5:33pm UTC](https://community.openfn.org/t/exporting-and-importing-data/342/10 "2023-08-02T17:33:36Z")

</div>

Hey Mahao! Let’s move to email—shoot me and [justin@openfn.org](mailto:justin@openfn.org) and we’ll get something on the books!

---

<div class="post-metadata">

**Author:** ![taylordowns2000](https://community.openfn.org/user_avatar/community.openfn.org/taylordowns2000/32/165_2.png) [@taylordowns2000](https://community.openfn.org/u/taylordowns2000)\
**Post date:** [August 24, 2023, 9:07am UTC](https://community.openfn.org/t/exporting-and-importing-data/342/11 "2023-08-24T09:07:42Z")

</div>

@mahaomolise92 , `openfn pull <uuid>` is working well for me on cli version `0.4.0` and above – want to try updating with `npm install -g @openfn/cli` and seeing how it goes?

You can also bump the log level to debug: `openfn pull <some-project-uuid> -l debug`

Thanks! Let me know how it goes.

---

<div class="post-metadata">

**Author:** ![mahaomolise92](https://community.openfn.org/user_avatar/community.openfn.org/mahaomolise92/32/135_2.png) [@mahaomolise92](https://community.openfn.org/u/mahaomolise92)\
**Post date:** [August 25, 2023, 7:50am UTC](https://community.openfn.org/t/exporting-and-importing-data/342/12 "2023-08-25T07:50:54Z")

</div>

I am on version  
0.4.0  
and this is what I get  
[CLI] ❯ reading spec from /home/mahao/projects/lightning\_export/Lightning/project.yaml  
[CLI] ❯ validated spec: {  
“errors”: [  
{  
“context”: {  
“error”: “Not Found”  
},  
“message”: “Project must have a name”  
},  
{  
“message”: “workflows: must be a map”,  
“path”: [  
“workflows”  
]  
}  
],  
“doc”: {  
“error”: “Not Found”  
}  
}  
[CLI] ✘ ERROR: invalid spec  
[CLI] ✘ [  
{  
“context”: {  
“error”: “Not Found”  
},  
“message”: “Project must have a name”  
},  
{  
“message”: “workflows: must be a map”,  
“path”: [  
“workflows”  
]  
}  
]

---

<div class="post-metadata">

**Author:** ![taylordowns2000](https://community.openfn.org/user_avatar/community.openfn.org/taylordowns2000/32/165_2.png) [@taylordowns2000](https://community.openfn.org/u/taylordowns2000)\
**Post date:** [August 28, 2023, 9:45am UTC](https://community.openfn.org/t/exporting-and-importing-data/342/13 "2023-08-28T09:45:55Z")

</div>

Hrmmm, I know that the endpoint paths have changed… can you try `0.4.1` with another `npm install -g @openfn/cli` and test out the following?

Configuration:

```json
{
  "apiKey": "<your-secret-here>",
  "endpoint": "https://demo.openfn.org",
  "statePath": ".state.json",
  "specPath": ".project.yaml"
}

```

Command: `openfn pull <your-project-uuid> -l debug -c ./tmp/.config.json` ?

Note that the endpoint is no longer the api path, but the host (should probably be renamed at some point) and you’re pointing to your config file in the command itself.

For me, running on the demo site with the credentials from the demo superuser, I get this:

```sh
openfn pull 4adf2644-ed4e-4f97-a24c-ab35b3cb1efa -l debug -c ./tmp/.config.json
[CLI] ♦ Downloading existing project state (as JSON) from the server.
Checking https://demo.openfn.org/api/provision/4adf2644-ed4e-4f97-a24c-ab35b3cb1efa for existing project.
Project found.
[CLI] ♦ Downloading the project spec (as YAML) from the server.
[CLI] ❯ Fetching project spec from "https://demo.openfn.org/api/provision/yaml?id=4adf2644-ed4e-4f97-a24c-ab35b3cb1efa"
[CLI] ❯ reading spec from /Users/taylor/openfn/kit/packages/cli/.project.yaml
[CLI] ✔ Project pulled successfully

```

And it creates a new `project.yaml` and `state.json` file in my working directory.
