# Inconsistency while importing workflows & credentials

**URL:** <https://community.n8n.io/t/inconsistency-while-importing-workflows-credentials/17383>\
**Category:** Questions\
**Tags:** deployment, cli\
**Created:** [September 5, 2022, 12:21pm UTC](https://community.n8n.io/t/inconsistency-while-importing-workflows-credentials/17383 "2022-09-05T12:21:19Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![hansenquadros](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/hansenquadros/32/16841_2.png) [@hansenquadros](https://community.n8n.io/u/hansenquadros)\
**Post date:** [September 5, 2022, 12:21pm UTC](https://community.n8n.io/t/inconsistency-while-importing-workflows-credentials/17383/1 "2022-09-05T12:21:19Z")

</div>

## Issue

While importing workflows & credentials into a new docker container only partial workflows & credentials get imported and not all of them present in the export json. Also, on re-import on the new docker container, duplicates of the workflows & credentials imported previously get created with different workflow ids

## Information on the n8n setup

- **n8n version:** 0.191.1
- **Database you’re using:** postgress 13
- **Running n8n via:** Docker compose with workers in different containers

---

<div class="post-metadata">

**Author:** ![MutedJam](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/mutedjam/32/70851_2.png) [@MutedJam](https://community.n8n.io/u/MutedJam)\
**Post date:** [September 5, 2022, 12:24pm UTC](https://community.n8n.io/t/inconsistency-while-importing-workflows-credentials/17383/2 "2022-09-05T12:24:09Z")

</div>

Hi @hansenquadros, welcome to the community!

I am very sorry to hear you’re having trouble. Any chance you can provide an example of how to reproduce this (share a workflow which is only imported partially and the export/import commands used here)?

---

<div class="post-metadata">

**Author:** ![hansenquadros](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/hansenquadros/32/16841_2.png) [@hansenquadros](https://community.n8n.io/u/hansenquadros)\
**Post date:** [September 5, 2022, 12:40pm UTC](https://community.n8n.io/t/inconsistency-while-importing-workflows-credentials/17383/3 "2022-09-05T12:40:21Z")

</div>

## In Fetch Test Workflow python script conains

Using Python GitLab API  
f\_flow = project.files.get(file\_path=‘n8n\_flows.json’, ref=‘n8n\_flow\_backups’)  
f\_auth = project.files.get(file\_path=‘n8n\_flows\_auth.json’, ref=‘n8n\_flow\_backups’)

with open(“/data/prod/n8n\_flows.json”, “wb”) as outfile:  
outfile.write(f\_flow.decode())

with open(“/data/prod/n8n\_flows\_auth.json”, “wb”) as outfile:  
outfile.write(f\_auth.decode())

## In Modify Test to Prod Workflow python script conains

with open(‘/data/prod/n8n\_flows.json’, ‘r’) as file :  
test\_workflow = file.read()

replace\_string\_patterns = [  
{  
‘old’: ‘(Test Flow)’,  
‘new’: ‘(Prod Flow)’  
}, …  
]

for pattern in replace\_string\_patterns:  
test\_workflow = test\_workflow.replace(pattern[‘old’], pattern[‘new’])

prod\_workflow\_json = json.loads(test\_workflow)

with open(“/data/prod/n8n\_flows\_prod.json”, “w”) as outfile:  
outfile.write(test\_workflow)

---

<div class="post-metadata">

**Author:** ![MutedJam](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/mutedjam/32/70851_2.png) [@MutedJam](https://community.n8n.io/u/MutedJam)\
**Post date:** [September 5, 2022, 12:43pm UTC](https://community.n8n.io/t/inconsistency-while-importing-workflows-credentials/17383/4 "2022-09-05T12:43:00Z")

</div>

Thanks @hansenquadros. any chance you can share a workflow that isn’t imported as expected when using `n8n import:workflow --input=/data/prod/n8n_flows.json`? And can you confirm how exactly you have exported it in the first place?

---

<div class="post-metadata">

**Author:** ![hansenquadros](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/hansenquadros/32/16841_2.png) [@hansenquadros](https://community.n8n.io/u/hansenquadros)\
**Post date:** [September 5, 2022, 1:02pm UTC](https://community.n8n.io/t/inconsistency-while-importing-workflows-credentials/17383/5 "2022-09-05T13:02:06Z")

</div>

## Export workflow

## In Push to GitLab

Using Python GitLab API  
data = {  
‘branch’: ‘n8n\_flow\_backups’,  
‘commit\_message’: str(datetime.datetime.now().date()),  
‘actions’: [  
{  
# Binary files need to be base64 encoded  
‘action’: ‘update’,  
‘file\_path’: ‘n8n\_flows.json’,  
‘content’: base64.b64encode(open(‘/data/test/n8n\_flows.json’,‘rb’).read()).decode(),  
‘encoding’: ‘base64’  
},  
{  
# Binary files need to be base64 encoded  
‘action’: ‘update’,  
‘file\_path’: ‘n8n\_flows\_auth.json’,  
‘content’: base64.b64encode(open(‘/data/test/n8n\_flows\_auth.json’,‘rb’).read()).decode(),  
‘encoding’: ‘base64’  
}  
]  
}

commit = project.commits.create(data)

---

<div class="post-metadata">

**Author:** ![MutedJam](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/mutedjam/32/70851_2.png) [@MutedJam](https://community.n8n.io/u/MutedJam)\
**Post date:** [September 5, 2022, 2:29pm UTC](https://community.n8n.io/t/inconsistency-while-importing-workflows-credentials/17383/6 "2022-09-05T14:29:11Z")

</div>

Hey @hansenquadros, I tried exporting the example workflow you have provided using `n8n export:workflow --all --output=./test.json` against a test instance running n8n@0.191.1. This has worked fine:

![image](https://europe1.discourse-cdn.com/n8n/original/3X/c/6/c6592a6afeefe1bae8852ca977ff058fc85074ba.png)

I have then deleted this workflow from my instance, before re-importing it again which has also worked:

![image](https://europe1.discourse-cdn.com/n8n/original/3X/7/b/7b493fa5b1fb13842228f8751ff01532efdbb8ed.png)

I can access the imported workflow in n8n as expected and it doesn’t seem to be corrupted in any way:

 ![image](https://europe1.discourse-cdn.com/n8n/original/3X/4/8/485a0dc5c5b62dd24342cd45e722c1f81d2f3730.png)

So I am afraid I can’t reproduce the problem based on your description.

---

<div class="post-metadata">

**Author:** ![hansenquadros](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/hansenquadros/32/16841_2.png) [@hansenquadros](https://community.n8n.io/u/hansenquadros)\
**Post date:** [September 8, 2022, 6:20am UTC](https://community.n8n.io/t/inconsistency-while-importing-workflows-credentials/17383/7 "2022-09-08T06:20:07Z")

</div>

Hey @MutedJam, got the issue solved by moving from Postgres DB to MySQL DB. I feel the issue was caused because of Postgres’s strict auto increment on workflows import that was changing worflow ids.

---

<div class="post-metadata">

**Author:** ![MutedJam](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/mutedjam/32/70851_2.png) [@MutedJam](https://community.n8n.io/u/MutedJam)\
**Post date:** [September 8, 2022, 12:48pm UTC](https://community.n8n.io/t/inconsistency-while-importing-workflows-credentials/17383/8 "2022-09-08T12:48:22Z")

</div>

Glad to hear you solved it, thanks so much for confirming! As mentioned, I couldn’t reproduce this myself, but I’ll add it to our internal ideas list for a closer look by the product and engineering teams going forward.

---

<div class="post-metadata">

**Author:** ![prashant](https://avatars.discourse-cdn.com/v4/letter/p/51bf81/32.png) [@prashant](https://community.n8n.io/u/prashant)\
**Post date:** [February 7, 2023, 4:47pm UTC](https://community.n8n.io/t/inconsistency-while-importing-workflows-credentials/17383/10 "2023-02-07T16:47:29Z")

</div>

We are facing similar issue. However we cannot move to Mysql easily.  
Can this issue be resolved by core team for Postgres and other SQL stores?

---

<div class="post-metadata">

**Author:** ![MutedJam](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/mutedjam/32/70851_2.png) [@MutedJam](https://community.n8n.io/u/MutedJam)\
**Post date:** [February 14, 2023, 2:33pm UTC](https://community.n8n.io/t/inconsistency-while-importing-workflows-credentials/17383/11 "2023-02-14T14:33:37Z")

</div>

Hi @prashant, which version of n8n are you using? This PostgreSQL problem was resolved with version n8n@0.213.0: [n8n/CHANGELOG.md at master · n8n-io/n8n · GitHub](https://github.com/n8n-io/n8n/blob/master/CHANGELOG.md#02130-2023-01-27)

If you are still facing any issues here, could you open a new thread with detailed steps on how to reproduce these?

---

<div class="post-metadata">

**Author:** ![MutedJam](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/mutedjam/32/70851_2.png) [@MutedJam](https://community.n8n.io/u/MutedJam)\
**Post date:** [February 21, 2023, 2:34pm UTC](https://community.n8n.io/t/inconsistency-while-importing-workflows-credentials/17383/12 "2023-02-21T14:34:32Z")

</div>

Closed on February 21, 2023, 2:34pm UTC

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
