Skip to main content
Entirius
AI platform for e-commerce
Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

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.

Prerequisites

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 webapp user that runs the n8n service.

Step 1: The Critical Encryption Key

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.

  1. 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/config
    

    Look for a line similar to this and copy the long string of characters:
    "encryptionKey": "your-very-long-and-secret-encryption-key"

  2. 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 n8n
    

    Edit the .env file to add the encryption key.

    vim /home/webapp/.n8n/.env
    

    Add 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-key
    

    Delete 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/config
    
  3. Restart 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
    

Step 2: Exporting Data from the Old Instance

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-export
    
  • Export 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.json
    
  • Checking

    You should now have workflows.json and credentials.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.json
    
  • Export users data to csv file

    Install sqlite3 tools on Ubuntu

    sudo apt install sqlite3
    

    Ensure database file exists

    ls -la ~/.n8n/database.sqlite
    

    Export 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;"
    

Step 3: Importing Data to the New Instance

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, use scp to 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.

    1. As an administrator, navigate to Settings / User.
    2. Prepare a comma-separated list of emails from your users.csv file (e.g., [email protected], [email protected]).
    3. 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 n8n
    
  • Run 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.json
    
  • Your data should now be migrated.

    Start the n8n service again.

    sudo systemctl start n8n
    sudo systemctl status n8n # Check that it is running correctly
    

Step 4: Verification and Finalization

Your data should now be migrated.

  1. *Start the Service

    Start the n8n service again.

    sudo systemctl start n8n
    sudo systemctl status n8n # Check that it is running correctly
    
  2. Log In and Check

    Access your new n8n instance. Verify that all workflows and credentials are present in the UI.