How to Migrate n8n: Export & Import Credentials and Workflows

Recently, I wanted to migrate my n8n instance from a SQLite-based setup to a more robust solution.

I began reviewing the guide provided by n8n, but I found it confusing and difficult to understand.

As someone who has never used Docker, I struggled to figure out how to get started with it.

How to Migrate n8n: Export & Import Credentials and Workflows

How to Migrate n8n: Export Credentials and Workflows

  • Login to your server.
ssh root@ip-address
  • Run the command to retrieve the list of containers.
docker ps | grep n8n
  • Find your container name, and then run the following command to export the credentials.
docker exec -u node -it <container_name> n8n export:credentials --all --decrypted > credentials.json
  • Now, it’s time to implement it for workflows.
docker exec -u node -it <container_name> n8n export:workflow --all > workflows.json
  • Now you can verify whether the workflows have been exported correctly by using this command.
ls -la workflows.json credentials.json

How to Migrate n8n: Import Credentials and Workflows

  • Firstly, ensure that you copy and paste these two files to your new server using the SCP command.
scp workflows.json credentials.json root@new-server-ip:/home
  • Then, find the name of the new container where your n8n is hosted by following the steps provided above. After that, copy and paste the files correctly.
docker cp workflows.json <new_container_name>:/tmp/workflows.json
docker cp credentials.json <new_container_name>:/tmp/credentials.json
  • Verify that the files are correctly present inside the container.
docker exec -u node -it <new_container_name> ls -la /tmp/
  • You need to begin by importing the credentials.
docker exec -u node -it <new_container_name> n8n import:credentials --input=/tmp/credentials.json
  • Now, please proceed with the workflows.
docker exec -u node -it <new_container_name> n8n import:workflow --input=/tmp/workflows.json
  • That’s it! Now, just remember to restart the container once the work is done.
docker restart <new_container_name>
  • Also, remember to clean up the files.
docker exec -u node -it <new_container_name> rm /tmp/workflows.json /tmp/credentials.json
  • That’s it! You’ve successfully moved your workflows. If you encounter any issues during the process, please comment below, and let’s work together to resolve them.

Leave a Comment