How to migrate an n8n configuration between two VPS

Objective

This guide explains how to transfer an existing n8n configuration to an OVHcloud VPS, or from an OVHcloud VPS to another instance. You can choose either the export/import method via the CLI commands of n8n, or the backup/restore of the .n8n folder.

Requirements

  • Two functional VPS (OVHcloud or others)
  • Administrative (sudo) access to your server via SSH

Instructions

Tip

If you are starting from scratch, opt for an OVHcloud preinstalled n8n VPS to get started quickly.

Summary

Method 1 - Export and import via n8n CLI

n8n provides commands for exporting and importing your workflows and credentials.

Depending on your installation, you have two options:

  • n8n installed in CLI mode (npm or binary): directly type n8n export:... from your VPS.
  • n8n installed via Docker (OVHcloud case with image n8nio/n8n): run the commands inside the container with docker exec.

Step 1 - Log in to the source VPS

Open a terminal and connect via SSH to your VPS on which n8n is installed:

ssh <user>@<IP_VPS_SOURCE>

Step 2 - Export workflows

Info

The paths indicated (/home/node/...) correspond to the default Docker installation of n8n. If you have customized the volumes or paths in your Docker Compose configuration, adjust them accordingly.

Case A - Native CLI Installation
Case B - Installation via Docker

Run the following command to export all workflows to a file:

n8n export:workflow --all --output=workflows.json

Step 3 - Export credentials

Case A - Native CLI Installation
Case B - Installation via Docker

Run the following command to export all decrypted credentials to a JSON file:

n8n export:credentials --all --decrypted --output=credentials.json

Step 4 - Transfer the exported files

Copy the generated files (workflows.json and credentials.json) to your target VPS:

scp workflows.json credentials.json <user>@<TARGET_VPS_IP>:/root/
Info

In the example, we transfer the files to the /root/ directory of the target VPS. You can choose another directory if required, depending on your access rights.

Step 5 - Import workflows

Connect via SSH to your target VPS:

ssh <user>@<TARGET_VPS_IP>
Case A - Native CLI Installation
Case B - Installation via Docker
n8n import:workflow --input=workflows.json

Step 6 - Import credentials

Case A - Native CLI Installation
Case B - Installation via Docker
n8n import:credentials --input=credentials.json

Method 2 - Backup and restore the .n8n folder

With this method, you can transfer the entire configuration (workflows, credentials and settings) between two instances.

Where is the .n8n folder located?

  • CLI installation (npm or binary): The folder is usually in the home directory of the user running n8n, for example /root/.n8n or /home/<user>/.n8n.
  • Docker installation: The folder is located in the container at the location /home/node/.n8n. In most Docker Compose configurations, it is mounted in a volume named n8n_data or in a folder on the VPS (e.g. /root/n8n_data:/home/node/.n8n).

Check its location with:

docker exec -it n8n ls -lah /home/node/.n8n
docker inspect n8n | grep -A 5 Mounts

Step 1 - Save the folder .n8n

Case A - Native CLI Installation
Case B - Installation via Docker

Create the archive directly from the host system:

tar czvf n8n-backup.tar.gz /root/.n8n

Step 2 - Transfer the archive to the target VPS

Send the file to your target VPS:

scp n8n-backup.tar.gz <user>@<TARGET_VPS_IP>:/root/

Connect via SSH to your target VPS:

ssh <user>@<TARGET_VPS_IP>

Step 3 - Restore the archive on the target VPS

On your target VPS, restore the archive in the .n8n folder of the container:

docker exec -i n8n sh -c 'tar xzvf - -C /home/node/.n8n' < n8n-backup.tar.gz

Step 4 - Restart n8n

Restart n8n:

docker start n8n
Warning

This method requires that the encryption key (encryptionKey) is identical between the two instances. Check or copy this setting from your source instance’s configuration file.

Points to note

After migration, if the domain or subdomain changes (e.g. n8n.mydomain.comn8n.ovh.net), update:

  • The N8N_HOST variable in your docker-compose.yml file.
  • Your DNS zone so that the subdomain points to the IP address of the new VPS.

To find out more, read our guide Modifying an OVHcloud DNS zone.

Conclusion

You now have two methods for migrating your n8n workflows and credentials to an OVHcloud VPS (or from OVHcloud to another environment):

  • Export/Import via CLI: simple and selective.
  • Backup .n8n: full, ideal for a full migration.

For more information, please refer to the official n8n documentation.

Go further

How to install n8n on an OVHcloud VPS

Join our community of users.

Was this page helpful?