Credentials "transfer" using dumped SQL table

Describe the problem/error/question

I exported the credentials table from a self-hosted n8n with intention of restoring it on another instance. The credentials appeared on the second. However, they show up as “Waiting first use” or something like that. Since the credentials are stored in base64, I suppose there is no easy way to recover due its salt.

What is the error message (if any)?

Credential with ID “efCtVfO9hmh95bYS” could not be found.

How can I transfer credentials from one instance to another in a self-hosted environment without duplicating the whole database?

Information on your n8n setup

  • n8n version: 1.95.4
  • Database: Postgres
  • n8n EXECUTIONS_PROCESS setting: main
  • Running n8n via: Docker
  • Operating system: Ubuntu 20.04

n8n encrypts credentials using a private key generated per instance upon initial startup. This key is used to decrypt Base64 data (although the contents are visible, it’s useless without the key).

By default, this key is saved in a file in the container called:
/home/node/.n8n/config

Or if you define your own persistence volume, it might look like this:
/home/node/.n8n/encryption.key

Why can’t the credentials be read after the migration?
Because the encryption key (encryptionKey) is different on the second instance.
So, even if the logs are present, n8n can’t decrypt them.

Exporting and Importing Credentials in n8n
Exporting Credentials: You can export all credentials in plain text using the following command:
n8n export:credentials --all --decrypted --output=credentials.json

Importing Credentials: To import the exported credentials into a new n8n instance, use:
n8n import:credentials --input=credentials.json

Make sure the new instance has the N8N_ENCRYPTION_KEY environment variable set correctly if you are using a custom key.

Please note that when exporting credentials in plain text, all sensitive information will be visible in the file. Therefore, handle this file with caution and delete it once the migration is complete.

If you need more details or additional assistance, please don’t hesitate to ask.

2 Likes

I performed exactly what you mentioned, it worked like a charm. For workflows, I ssh tunneled the files to the new instance server, then copied inside the editor container and imported with a command. Thanks for the assistance!

1 Like