Self-Hosted n8n: Updating, Backing Up and Securing Your Instance
Short answer: A self-hosted n8n instance needs four habits. Update it on a schedule by reading the release notes, backing up, pulling the new Docker image and restarting. Back up both the database (SQLite file or Postgres dump) and the encryption key, because credentials stored in the database cannot be decrypted without the key. Export workflows to files as a second, readable copy. And keep it locked down: HTTPS through a reverse proxy, user accounts instead of shared logins, two-factor authentication where available, and only the webhook paths you need exposed to the internet. Plan about half an hour a month.
Know what makes up your instance
Before building a routine, write down how your server is set up. A typical small business deployment on a VPS looks like this:
| Part | Where it lives | Why it matters |
|---|---|---|
| n8n application | Docker image, started by Docker Compose | Replaced on every update |
| Data folder | Volume mounted at /home/node/.n8n |
Holds settings, the generated encryption key, and SQLite database if used |
| Database | SQLite file in the data folder, or a separate Postgres container | Workflows, credentials, execution history |
| Environment variables | docker-compose.yml or a separate env file |
Host name, webhook URL, encryption key, database settings |
| Reverse proxy | Caddy, Traefik or Nginx container | HTTPS certificates, which ports are public |
The Docker installation guide in the n8n docs shows the standard layout. If your setup differs, note where yours deviates.
The encryption key: protect it first
n8n encrypts stored credentials (API keys, OAuth tokens, passwords) with an encryption key. If you did not set one yourself, n8n generated it on first start and saved it in a config file inside the data folder.
- If you lose the data folder and have only a database backup, every credential is unreadable and must be re-entered by hand.
- If you run more than one n8n process, such as queue mode with workers, they must all use the same key.
Recommended steps:
- Find the current key in the config file within the data folder.
- Set it explicitly with the
N8N_ENCRYPTION_KEYvariable in your environment configuration, as described in the environment variables reference, so it no longer depends on that file. - Store a copy in your password manager, separate from the server backups.
Never commit the key or env file to a public repository or paste it into chat tools.
Backing up the database and files
Back up on a schedule, to storage outside the server:
- SQLite: stop the container briefly, or use SQLite's backup command, then copy
database.sqlitefrom the data folder. Copying a live SQLite file while n8n writes to it can produce a corrupt backup. - Postgres: run
pg_dumpagainst the n8n database from a cron job, compress the file and upload it to object storage. - Data folder: archive the whole
.n8nvolume, which also captures the config and any custom nodes. - Configuration: keep a copy of
docker-compose.ymland the env file in your password manager or a private repository.
Then test a restore at least once: spin up a fresh server or local Docker, restore the backup, set the same key, and confirm a workflow with credentials runs.
Exporting workflows as a second copy
Database backups are complete but not readable. Workflow exports give you JSON files you can browse, compare and import individually. From inside the container:
docker compose exec n8n n8n export:workflow --all --output=/home/node/.n8n/backups/workflows.json
Use --separate with a folder path to write one file per workflow, which suits version control. Credentials can be exported with a similar command, but decrypted exports contain secrets in plain text, so avoid them unless you are migrating and delete the file right after.
Updating with Docker step by step
n8n releases frequently. Updating monthly, rather than skipping a year, keeps each jump small.
- Read the release notes for every version between yours and the target. Look for breaking changes, changed node behavior, and new required settings.
- Back up the database and data folder as above.
- Pin the version. In
docker-compose.yml, set the image tag to a specific version rather thanlatest, so you control exactly what you get. - Pull and restart:
docker compose pullfollowed bydocker compose up -d. - Watch the logs with
docker compose logs -f n8nfor database migration messages and errors. - Test critical workflows. Open each production workflow, check for nodes marked as needing an update, and run a test execution or wait for the next scheduled run.
- Roll back if needed by changing the tag back and restoring the pre-update backup. Database migrations may not run backwards, which is why the backup comes first.
Also update the host itself: apply operating system security updates and keep Docker current.
Access control and HTTPS
Exposed automation servers are attractive targets, because they hold keys to your other systems.
- HTTPS only. Put n8n behind a reverse proxy that obtains certificates automatically, and do not publish n8n's own port directly to the internet. Set the host, protocol and webhook URL variables so links and webhooks use the HTTPS address.
- Individual accounts. Use the built-in user management: one owner, and separate accounts for each person who builds workflows. Remove accounts when people leave.
- Two-factor authentication for every user where your version offers it.
- Firewall. Allow only ports 80 and 443 (and SSH from known addresses) on the VPS.
- Limit what is public. Webhook URLs are reachable by anyone who knows them. Use header authentication on webhook nodes where possible, avoid predictable paths, and deactivate test workflows that expose endpoints.
- Execution data. Configure execution pruning so old runs, which can contain customer data, are deleted after a set number of days.
A monthly routine
- [ ] Read release notes and update to a pinned newer version
- [ ] Confirm last night's backup exists off-server and is a sensible size
- [ ] Export workflows to the backup folder
- [ ] Review users and remove any who no longer need access
- [ ] Check for failed executions and expired credentials
- [ ] Apply server OS updates and reboot if required
FAQ
Can I move from SQLite to Postgres later?
Yes. The usual route is exporting workflows and credentials with the CLI, starting a new instance on Postgres with the same encryption key, and importing them. Test on a copy first.
What happens if I update without reading the notes?
Most updates go smoothly, but occasionally a node changes behavior or a setting becomes required. Reading the notes takes minutes and avoids broken production workflows.
Is self-hosting less secure than n8n Cloud?
It can be as secure, but security becomes your responsibility. If nobody on the team will keep this routine, the managed service may be the safer choice.
If you would like a hand setting up backups, updates and HTTPS for your n8n server, tell us how it runs today and we will help put a routine in place.