# N8N

Tutorial and various scripts relative to N8N and also some ready workflows.

# N8N Upgrade Script

This script automates upgrading a <span style="color:rgb(224,62,45);">**non-Docker**</span> n8n installation on Debian by stopping the ***systemd service***, backing up your n8n data, upgrading n8n via npm to `n8n@latest`, then starting the service again with clear colored status messages at each step.

### What the script does

- Checks it is running as root (requires `sudo`) and aborts if not.
- Verifies the systemd service exists (default service name is `n8n`) and stops it before upgrading.
- Creates a timestamped backup of the `.n8n` directory into `~/n8n_backups/` for the configured `N8N_USER` (default `root`), then proceeds even if backup fails.
- Runs `npm install -g n8n@latest --unsafe-perm=true`, prints the new `n8n --version`, starts the service, and performs a final `systemctl is-active` health check.

#### Install + run (one line)

Host the script at a URL (for example `https://YOUR-DOMAIN/n8n-upgrade.sh`) and run it with a one-liner like this (downloads and executes immediately):

```bash
curl -fsSL https://docs.greenhome.stream/attachments/63 | sudo bash
```

Alternative with wget:\[^1\]

```bash
wget -qO- https://docs.greenhome.stream/attachments/63 | sudo bash
```

#### Before first use (important)

Edit the variables at the top of the script so they match your system: set `SERVICE_NAME` to your systemd unit name (default `n8n`) and set `N8N_USER` to the Linux user that owns the n8n data directory you want to back up (default `root`).

If you don’t set `N8N_USER` correctly, the script may not find `~N8N_USER/.n8n` and will skip the backup step.

### How to verify and troubleshoot

If the script ends with “Update Complete”, it has verified the service is active via systemd.

If something fails or n8n doesn’t start, check logs exactly as the script suggests: `journalctl -u n8n -f` (replace `n8n` with your `SERVICE_NAME`).

If you tell me your actual systemd service name and which user owns the n8n data folder, I can tailor the description and the one-liner command to your exact setup.

<div class="notranslate" id="bkmrk-"></div>

# Install N8N dependencies