diff --git a/pages/bare_metal_cloud/virtual_private_servers/import-export-n8n/guide.en-gb.md b/pages/bare_metal_cloud/virtual_private_servers/import-export-n8n/guide.en-gb.md new file mode 100644 index 00000000000..51d529af879 --- /dev/null +++ b/pages/bare_metal_cloud/virtual_private_servers/import-export-n8n/guide.en-gb.md @@ -0,0 +1,273 @@ +--- +title: "How to migrate an n8n configuration between two VPS" +excerpt: "Find out how to export and import a complete n8n configuration (workflows and credentials) from an external VPS to an OVHcloud VPS, and vice versa." +updated: 2025-09-04 +--- + +## 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](/links/bare-metal/vps) (OVHcloud or others) +- Administrative (sudo) access to your server via SSH + +## Instructions + +### Summary + +- [Method 1: Export and import via n8n CLI](#method1) +- [Method 2: Backup and restore the `.n8n` folder](#method2) +- [Points to note](#importantNotes) +- [Conclusion](#conclusion) + +### 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: + +```bash +ssh @ +``` + +#### Step 2 - Export workflows + +> [!primary] +> +> 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. + +> [!tabs] +> Case A - Native CLI Installation +>> +>> Run the following command to export all workflows to a file: +>> +>> ```bash +>> n8n export:workflow --all --output=workflows.json +>> ``` +>> +> Case B - Installation via Docker +>> +>> Identify the name of your n8n container (default is `n8n`): +>> +>> ```bash +>> docker ps +>> ``` +>> +>> Run the following command to generate the file inside the container: +>> +>> ```bash +>> docker exec -it n8n n8n export:workflow --all --output=/home/node/workflows.json +>> ``` +>> +>> Sample output: +>> +>> ![Import export n8n](images/workflow_successfully_exported.png){.thumbnail} +>> +>> Output the file from the container to place it in the file system of the source VPS: +>> +>> ```bash +>> docker cp n8n:/home/node/workflows.json /root/workflows.json +>> ``` +>> +>> Sample output: +>> +>> ![Import export n8n](images/workflow_successfully_copied.png){.thumbnail} +>> + +#### Step 3 - Export credentials + +> [!tabs] +> Case A - Native CLI Installation +>> +>> Run the following command to export all decrypted credentials to a JSON file: +>> +>> ```bash +>> n8n export:credentials --all --decrypted --output=credentials.json +>> ``` +>> +> Case B - Installation via Docker +>> +>> Run this command in the n8n container to generate the decrypted credentials file: +>> +>> ```bash +>> docker exec -it n8n n8n export:credentials --all --decrypted --output=/home/node/credentials.json +>> ``` +>> +>> Sample output: +>> +>> ![Import export n8n](images/credentials_successfully_exported.png){.thumbnail} +>> +>> > [!warning] +>> > +>> > Use the `--decrypted` option if you are migrating to another instance to avoid encryption errors. Handle this file carefully as it contains sensitive data. +>> +>> Copy this file to the file system of the source VPS: +>> +>> ```bash +>> docker cp n8n:/home/node/credentials.json /root/credentials.json +>> ``` +>> +>> Sample output: +>> +>> ![Import export n8n](images/credentials_successfully_copied.png){.thumbnail} +>> + +#### Step 4 - Transfer the exported files + +Copy the generated files (`workflows.json` and `credentials.json`) to your target VPS: + +```bash +scp workflows.json credentials.json @:/root/ +``` + +> [!primary] +> +> 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: + +```bash +ssh @ +``` + +> [!tabs] +> Case A - Native CLI Installation +>> +>> ```bash +>> n8n import:workflow --input=workflows.json +>> ``` +>> +> Case B - Installation via Docker +>> +>> ```bash +>> docker exec -it n8n n8n import:workflow --input=/home/node/workflows.json +>> ``` + +#### Step 6 - Import credentials + +> [!tabs] +> Case A - Native CLI Installation +>> +>> ```bash +>> n8n import:credentials --input=credentials.json +>> ``` +>> +> Case B - Installation via Docker +>> +>> ```bash +>> docker exec -it n8n n8n import:credentials --input=/home/node/credentials.json +>> ``` +>> +>> > [!primary] +>> > +>> > When importing, if a workflow or credential ID already exists in the target instance, it will be overwritten. To avoid conflicts, change or delete the ID in the JSON files before importing. +>> +>> > [!warning] +>> > +>> > Delete the `credentials.json` file from your source and target VPS after import to avoid any leakage of sensitive data. +>> + +### 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//.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: + +```bash +docker exec -it n8n ls -lah /home/node/.n8n +docker inspect n8n | grep -A 5 Mounts +``` + +#### Step 1 - Save the folder `.n8n` + +> [!tabs] +> Case A - Native CLI Installation +>> +>> Create the archive directly from the host system: +>> +>> ```bash +>> tar czvf n8n-backup.tar.gz /root/.n8n +>> ``` +>> +> Case B - Installation via Docker +>> +>> Create an archive of the `.n8n` folder: +>> +>> ```bash +>> docker exec n8n tar czvf - /home/node/.n8n > n8n-backup.tar.gz +>> ``` +>> + +#### Step 2 - Transfer the archive to the target VPS + +Send the file to your target VPS: + +```bash +scp n8n-backup.tar.gz @:/root/ +``` + +Connect via SSH to your target VPS: + +```bash +ssh @ +``` + +#### Step 3 - Restore the archive on the target VPS + +On your target VPS, restore the archive in the `.n8n` folder of the container: + +```bash +docker exec -i n8n sh -c 'tar xzvf - -C /home/node/.n8n' < n8n-backup.tar.gz +``` + +#### Step 4 - Restart n8n + +Restart n8n: + +```bash +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.com` → `n8n.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](/pages/web_cloud/domains/dns_zone_edit). + +### 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](https://docs.n8n.io/hosting/cli-commands/). + +## Go further + +[How to install n8n on an OVHcloud VPS](/pages/bare_metal_cloud/virtual_private_servers/install_n8n_on_vps) + +Join our [community of users](/links/community). \ No newline at end of file diff --git a/pages/bare_metal_cloud/virtual_private_servers/import-export-n8n/guide.fr-fr.md b/pages/bare_metal_cloud/virtual_private_servers/import-export-n8n/guide.fr-fr.md new file mode 100644 index 00000000000..96adeda5232 --- /dev/null +++ b/pages/bare_metal_cloud/virtual_private_servers/import-export-n8n/guide.fr-fr.md @@ -0,0 +1,273 @@ +--- +title: "Comment migrer une configuration n8n entre deux VPS" +excerpt: "Découvrez comment exporter et importer une configuration n8n complète (workflows et identifiants) d’un VPS externe vers un VPS OVHcloud, et inversement." +updated: 2025-09-04 +--- + +## Objectif + +Ce guide vous explique comment transférer une configuration n8n existante vers un VPS OVHcloud, ou depuis un VPS OVHcloud vers une autre instance. Vous pouvez choisir soit la méthode d'export/import via les **commandes CLI de n8n**, soit la sauvegarde/restauration du dossier `.n8n`. + +## Prérequis + +- Disposer de deux [VPS](/links/bare-metal/vps) fonctionnels (OVHcloud ou autres) +- Disposer d'un accès administrateur (sudo) via SSH à votre serveur + +## En pratique + +### Sommaire + +- [Méthode 1 : Exporter et importer via la CLI n8n](#method1) +- [Méthode 2 : Sauvegarde et restauration du dossier `.n8n`](#method2) +- [Points d'attention](#importantNotes) +- [Conclusion](#conclusion) + +### Méthode 1 - Exporter et importer via la CLI n8n + +n8n fournit des commandes pour exporter et importer vos **workflows** et **credentials**. + +Selon votre installation, vous avez deux possibilités : + +- **n8n installé en mode CLI** (npm ou binaire) : tapez directement `n8n export:...` depuis votre VPS. +- **n8n installé via Docker** (cas OVHcloud avec l’image `n8nio/n8n`) : exécutez les commandes à l’intérieur du conteneur avec `docker exec`. + +#### Étape 1 - Connectez-vous au VPS source + +Ouvrez un terminal et connectez-vous en SSH à votre VPS où n8n est installé : + +```bash +ssh @ +``` + +#### Étape 2 - Exportez les workflows + +> [!primary] +> +> Les chemins indiqués (`/home/node/...`) correspondent à l’installation Docker par défaut de n8n. Si vous avez personnalisé les volumes ou les chemins dans votre configuration Docker Compose, adaptez-les en conséquence. + +> [!tabs] +> Cas A - Installation en CLI natif +>> +>> Exécutez la commande suivante pour exporter tous les workflows dans un fichier : +>> +>> ```bash +>> n8n export:workflow --all --output=workflows.json +>> ``` +>> +> Cas B - Installation via Docker +>> +>> Identifiez le nom de votre conteneur n8n (par défaut `n8n`) : +>> +>> ```bash +>> docker ps +>> ``` +>> +>> Exécutez la commande suivante pour générer le fichier à l’intérieur du conteneur : +>> +>> ```bash +>> docker exec -it n8n n8n export:workflow --all --output=/home/node/workflows.json +>> ``` +>> +>> Exemple de sortie : +>> +>> ![Import export n8n](images/workflow_successfully_exported.png){.thumbnail} +>> +>> Sortez le fichier du conteneur pour le placer dans le système de fichiers du VPS source : +>> +>> ```bash +>> docker cp n8n:/home/node/workflows.json /root/workflows.json +>> ``` +>> +>> Exemple de sortie : +>> +>> ![Import export n8n](images/workflow_successfully_copied.png){.thumbnail} +>> + +#### Étape 3 - Exportez les credentials + +> [!tabs] +> Cas A - Installation en CLI natif +>> +>> Exécutez la commande suivante pour exporter tous les credentials déchiffrés vers un fichier JSON : +>> +>> ```bash +>> n8n export:credentials --all --decrypted --output=credentials.json +>> ``` +>> +> Cas B - Installation via Docker +>> +>> Exécutez cette commande dans le conteneur n8n pour générer le fichier des credentials déchiffrés : +>> +>> ```bash +>> docker exec -it n8n n8n export:credentials --all --decrypted --output=/home/node/credentials.json +>> ``` +>> +>> Exemple de sortie : +>> +>> ![Import export n8n](images/credentials_successfully_exported.png){.thumbnail} +>> +>> > [!warning] +>> > +>> > Utilisez l’option `--decrypted` si vous migrez vers une autre instance pour éviter les erreurs de chiffrement. Manipulez ce fichier avec précaution car il contient des données sensibles. +>> +>> Copiez ce fichier vers le système de fichiers du VPS source : +>> +>> ```bash +>> docker cp n8n:/home/node/credentials.json /root/credentials.json +>> ``` +>> +>> Exemple de sortie : +>> +>> ![Import export n8n](images/credentials_successfully_copied.png){.thumbnail} +>> + +#### Étape 4 - Transférez les fichiers exportés + +Copiez les fichiers générés (`workflows.json` et `credentials.json`) vers votre VPS cible : + +```bash +scp workflows.json credentials.json @:/root/ +``` + +> [!primary] +> +> Dans l’exemple, nous transférons les fichiers vers le répertoire `/root/` du VPS cible. Vous pouvez choisir un autre répertoire si besoin, en fonction de vos droits d’accès. + +#### Étape 5 - Importez les workflows + +Connectez-vous en SSH à votre VPS cible : + +```bash +ssh @ +``` + +> [!tabs] +> Cas A - Installation en CLI natif +>> +>> ```bash +>> n8n import:workflow --input=workflows.json +>> ``` +>> +> Cas B - Installation via Docker +>> +>> ```bash +>> docker exec -it n8n n8n import:workflow --input=/home/node/workflows.json +>> ``` + +#### Étape 6 - Importez les credentials + +> [!tabs] +> Cas A - Installation en CLI natif +>> +>> ```bash +>> n8n import:credentials --input=credentials.json +>> ``` +>> +> Cas B - Installation via Docker +>> +>> ```bash +>> docker exec -it n8n n8n import:credentials --input=/home/node/credentials.json +>> ``` +>> +>> > [!primary] +>> > +>> > Lors de l’import, si un ID de workflow ou credential existe déjà dans l’instance cible, il sera écrasé. Pour éviter les conflits, modifiez ou supprimez l’ID dans les fichiers JSON avant import. +>> +>> > [!warning] +>> > +>> > Supprimez le fichier `credentials.json` de votre VPS source et cible après import pour éviter toute fuite de données sensibles. +>> + +### Méthode 2 - Sauvegarde et restauration du dossier `.n8n` + +Cette méthode permet de transférer l’intégralité de la configuration (workflows, credentials et paramètres) entre deux instances. + +#### Où se trouve le dossier `.n8n` ? + +- Installation CLI (npm ou binaire) : le dossier se trouve généralement dans le répertoire personnel de l’utilisateur qui exécute n8n, par exemple `/root/.n8n` ou `/home//.n8n`. +- Installation Docker : le dossier se trouve dans le conteneur à l’emplacement `/home/node/.n8n`. Dans la plupart des configurations Docker Compose, il est monté en volume nommé `n8n_data` ou dans un dossier du VPS (ex : `/root/n8n_data:/home/node/.n8n`). + +Vérifiez son emplacement avec : + +```bash +docker exec -it n8n ls -lah /home/node/.n8n +docker inspect n8n | grep -A 5 Mounts +``` + +#### Étape 1 - Sauvegardez le dossier `.n8n` + +> [!tabs] +> Cas A - Installation en CLI natif +>> +>> Créez l’archive directement depuis le système hôte : +>> +>> ```bash +>> tar czvf n8n-backup.tar.gz /root/.n8n +>> ``` +>> +> Cas B - Installation via Docker +>> +>> Créez une archive du dossier `.n8n` : +>> +>> ```bash +>> docker exec n8n tar czvf - /home/node/.n8n > n8n-backup.tar.gz +>> ``` +>> + +#### Étape 2 - Transférez l’archive vers le VPS cible + +Envoyez le fichier vers votre VPS cible : + +```bash +scp n8n-backup.tar.gz @:/root/ +``` + +Connectez-vous en SSH à votre VPS cible : + +```bash +ssh @ +``` + +#### Étape 3 - Restaurez l’archive sur le VPS cible + +Sur votre VPS cible, restaurez l’archive dans le dossier `.n8n` du conteneur : + +```bash +docker exec -i n8n sh -c 'tar xzvf - -C /home/node/.n8n' < n8n-backup.tar.gz +``` + +#### Étape 4 - Redémarrez n8n + +Relancez n8n : + +```bash +docker start n8n +``` + +> [!warning] +> +> Cette méthode nécessite que la **clé de chiffrement (`encryptionKey`)** soit identique entre les deux instances. Vérifiez ou copiez ce paramètre depuis le fichier de configuration de votre instance source. + +### Points d'attention + +Après la migration, si le domaine ou le sous-domaine change (par exemple `n8n.mydomain.com` → `n8n.ovh.net`), mettez à jour : + +- La variable `N8N_HOST` dans votre fichier `docker-compose.yml`. +- Votre zone DNS pour que le sous-domaine pointe vers l’adresse IP du nouveau VPS. + +Pour en savoir plus, consultez notre guide [Modifier une zone DNS OVHcloud](/pages/web_cloud/domains/dns_zone_edit) + +### Conclusion + +Vous disposez désormais de deux méthodes pour migrer vos workflows et credentials n8n vers un VPS OVHcloud (ou depuis OVHcloud vers un autre environnement) : + +- **Export/Import via CLI** : simple et sélectif. +- **Sauvegarde `.n8n`** : complet, idéal pour une migration totale. + +Pour plus d’informations, référez-vous à la [documentation officielle n8n](https://docs.n8n.io/hosting/cli-commands/). + +## Aller plus loin + +[Comment installer n8n sur un VPS OVHcloud](/pages/bare_metal_cloud/virtual_private_servers/install_n8n_on_vps) + +Échangez avec notre [communauté d'utilisateurs](/links/community). \ No newline at end of file diff --git a/pages/bare_metal_cloud/virtual_private_servers/import-export-n8n/images/credentials_successfully_copied.png b/pages/bare_metal_cloud/virtual_private_servers/import-export-n8n/images/credentials_successfully_copied.png new file mode 100644 index 00000000000..20ed4817ee9 Binary files /dev/null and b/pages/bare_metal_cloud/virtual_private_servers/import-export-n8n/images/credentials_successfully_copied.png differ diff --git a/pages/bare_metal_cloud/virtual_private_servers/import-export-n8n/images/credentials_successfully_exported.png b/pages/bare_metal_cloud/virtual_private_servers/import-export-n8n/images/credentials_successfully_exported.png new file mode 100644 index 00000000000..0cec04374e6 Binary files /dev/null and b/pages/bare_metal_cloud/virtual_private_servers/import-export-n8n/images/credentials_successfully_exported.png differ diff --git a/pages/bare_metal_cloud/virtual_private_servers/import-export-n8n/images/workflow_successfully_copied.png b/pages/bare_metal_cloud/virtual_private_servers/import-export-n8n/images/workflow_successfully_copied.png new file mode 100644 index 00000000000..0e735466d19 Binary files /dev/null and b/pages/bare_metal_cloud/virtual_private_servers/import-export-n8n/images/workflow_successfully_copied.png differ diff --git a/pages/bare_metal_cloud/virtual_private_servers/import-export-n8n/images/workflow_successfully_exported.png b/pages/bare_metal_cloud/virtual_private_servers/import-export-n8n/images/workflow_successfully_exported.png new file mode 100644 index 00000000000..2064f13dc07 Binary files /dev/null and b/pages/bare_metal_cloud/virtual_private_servers/import-export-n8n/images/workflow_successfully_exported.png differ diff --git a/pages/bare_metal_cloud/virtual_private_servers/import-export-n8n/meta.yaml b/pages/bare_metal_cloud/virtual_private_servers/import-export-n8n/meta.yaml new file mode 100644 index 00000000000..78b4ac5b078 --- /dev/null +++ b/pages/bare_metal_cloud/virtual_private_servers/import-export-n8n/meta.yaml @@ -0,0 +1,3 @@ +id: 73733185-6999-452d-83b6-982d803aa750 +full_slug: vps-import-export-n8n +reference_category: bare-metal-cloud-virtual-private-servers-tutorials \ No newline at end of file diff --git a/pages/index.md b/pages/index.md index d4e6338eab5..423c423e7ae 100644 --- a/pages/index.md +++ b/pages/index.md @@ -301,6 +301,7 @@ + [Automating the deployment of your website on your VPS via GitHub Actions](bare_metal_cloud/virtual_private_servers/deploy-website-github-actions) + [Automating the deployment of your website on your VPS via GitLab CI/CD](bare_metal_cloud/virtual_private_servers/deploy-website-gitlab-ci-cd) + [How to install N8N on an OVHcloud VPS](bare_metal_cloud/virtual_private_servers/install_n8n_on_vps) + + [How to migrate an n8n configuration between two VPS](bare_metal_cloud/virtual_private_servers/import-export-n8n) + [How to create and import a Lovable website on an OVHcloud VPS](bare_metal_cloud/virtual_private_servers/import-lovable-website-on-vps) + [How to install an AI agent on an OVHcloud VPS](bare_metal_cloud/virtual_private_servers/install-ia-agent-on-vps) + [Managed Bare Metal](products/bare-metal-cloud-managed-bare-metal)