Migrating n8n to the Entirius Platform
This guide outlines the recommended procedure for migrating your n8n data from a legacy instance using an SQLite database to a new, production-ready instance on the N8N Entirius Platform.
The new instance, deployed via the N8N Deployment procedure using entirius-scripts-kvm-deployer, utilizes PostgreSQL.
The primary method for this migration is the n8n Command Line Interface (CLI). This approach is safe, reliable, and ensures the stability of your old instance, as it only involves reading data without any modifications.
Before you begin, ensure you have the following:
- SSH access to the old n8n server.
- SSH access to the new server where the Entirius Platform n8n instance is deployed.
- The new instance uses the default
webappuser that runs the n8n service.
This is the most important step for a successful migration. Credentials in n8n are encrypted.
To ensure the new instance can decrypt them, both instances must share the same encryptionKey.
Locate the Key on the Old Instance:
Connect to your old server via SSH and find the
encryptionKey.
It is typically located in the n8n config file at~/.n8n/config.cat ~/.n8n/configLook for a line similar to this and copy the long string of characters:
"encryptionKey": "your-very-long-and-secret-encryption-key"Apply the Key to the New Instance:
On the new server, we need to apply the key and prevent any conflicts with auto-generated files.
Stop the n8n service to prevent it from interfering with our changes:sudo systemctl stop n8nEdit the
.envfile to add the encryption key.vim /home/webapp/.n8n/.envAdd the following line to the end of the file, pasting the key you copied from the old instance.
Do not use quotation marks.N8N_ENCRYPTION_KEY=your-very-long-and-secret-encryption-keyDelete the existing config file. This is a critical step to prevent the “Mismatching encryption keys” error.
n8n will recreate this file correctly on the next startup using the key from your .env file.rm -f /home/webapp/.n8n/configRestart the New Instance:
Force systemd to reload the configuration. This ensures it reads the updated .env file.
For the new key to be loaded, you must restart the n8n service.sudo systemctl daemon-reload sudo systemctl restart n8n
These commands read data from your old instance’s database and save it to JSON files.
This process is safe and will not interrupt the operation of your old instance.
Connect to the Old Server:
Use SSH to access the server where the old n8n instance is running.
Create export dir
mkdir ~/n8n-exportExport Workflows and Credentials:
Run the following command to export all workflows and credentials into.
n8n export:workflow --all --output=$HOME/n8n-export/workflows.json n8n export:credentials --all --output=$HOME/n8n-export/credentials.jsonChecking
You should now have
workflows.jsonandcredentials.json.$ ls -la ~/n8n-export/ total 528 drwxrwxr-x 2 webapp webapp 4096 Sep 25 10:43 . drwxr-x--- 12 webapp webapp 4096 Sep 25 10:22 .. -rw-rw-r-- 1 webapp webapp 35775 Sep 25 10:43 credentials.json -rw-rw-r-- 1 webapp webapp 492042 Sep 25 10:43 workflows.jsonExport users data to csv file
Install sqlite3 tools on Ubuntu
sudo apt install sqlite3Ensure database file exists
ls -la ~/.n8n/database.sqliteExport users data to csv
sqlite3 ~/.n8n/database.sqlite \ ".header on" \ ".mode csv" \ ".output /home/webapp/n8n-export/users.csv" \ "SELECT email, firstName, lastName, role, disabled FROM user;"
With the new instance running and correctly configured, you can now import the data.
Copy import files
First, create a local directory on the new server to store the import files.
Then, usescpto pull the exported files from the old server to this new directory.# Step 1: Create a directory on the NEW server (if it doesn't exist) mkdir -p ~/n8n-export # Step 2: Pull the files the OLD server # Replace user_on_old_server with your username on the OLD server # Replace old_server_ip with the IP address or domain of the OLD server scp user_on_old_server@old_server_ip:~/n8n-export/*.json ~/n8n-export/Manually Recreate Users:
Instead of creating user accounts one by one, you can invite multiple users to the platform simultaneously.
- As an administrator, navigate to Settings / User.
- Prepare a comma-separated list of emails from your
users.csvfile (e.g.,[email protected], [email protected]). - Paste this list into the New User Email Addresses field and send the invitations.
Users will receive an email to create their account and password.
Prepare for Import
First, stop the n8n service on the new server to prevent conflicts during the import process.
sudo systemctl stop n8nRun Import Commands
Import Credentials then Workflows:
export NVM_DIR="/home/webapp/.nvm" source /home/webapp/.nvm/nvm.sh cd ~/n8n-export npx dotenv-cli -e /home/webapp/.n8n/.env -- n8n import:credentials --input=credentials.json npx dotenv-cli -e /home/webapp/.n8n/.env -- n8n import:workflow --input=workflows.jsonYour data should now be migrated.
Start the n8n service again.
sudo systemctl start n8n sudo systemctl status n8n # Check that it is running correctly
Your data should now be migrated.
*Start the Service
Start the n8n service again.
sudo systemctl start n8n sudo systemctl status n8n # Check that it is running correctlyLog In and Check
Access your new n8n instance. Verify that all workflows and credentials are present in the UI.
