# n8n Disaster Recovery: How to Back Up and Restore Workflows and Data

Title: n8n Disaster Recovery: How to Back Up and Restore Workflows and Data
Canonical URL: https://backup.mrplanb.com/n8n-disaster-recovery
Author: Mr.PlanB
Language: en

Effective n8n disaster recovery requires backing up your `.n8n` directory, encryption key, database, and any external storage together. According to n8n's documentation, losing the original encryption key prevents restoring encrypted credentials even when your database backup is intact. How you build that recovery plan depends on whether you run self-hosted SQLite, PostgreSQL, queue mode, or n8n Cloud.

This guide covers n8n only. For what disaster recovery means in general, how a DR plan, RTO and RPO fit together and how cloud DR works, see [what is disaster recovery](https://backup.mrplanb.com/what-is-disaster-recovery-and-why-should-you-worry).

## What a complete n8n backup must include

Self-hosted n8n defaults to SQLite at `~/.n8n/database.sqlite` to store credentials, workflows, and past executions, and it also supports PostgreSQL. On first launch, n8n generates a credential encryption key inside `~/.n8n` unless you configure a custom `N8N_ENCRYPTION_KEY` environment variable. Because restoring a database or encrypted credential export requires its original encryption key, saving the database without that key leaves stored credentials unreadable.

A complete self-hosted backup covers the `.n8n` folder and, when using PostgreSQL, a separate database backup made with database tooling. Backups must also include any configured external binary or execution storage, custom filesystem storage paths, and custom-node directories.

As of November 2026, n8n's documented architecture spans five distinct backup and recovery approaches depending on how you host your instance.

| Deployment option | Primary data to protect | Key recovery requirement | Best suited for |
| --- | --- | --- | --- |
| Self-hosted SQLite | `.n8n` folder, SQLite file, environment variables | Original encryption key and consistent copy | Small self-hosted instances |
| Self-hosted PostgreSQL | `.n8n` folder, PostgreSQL dump, external storage | Matching database dump and encryption key | Larger self-hosted deployments |
| Server CLI exports | Workflow JSON files and credential JSON files | Host bind mount or copy out of container | Portable copies and migrations |
| Queue mode | PostgreSQL database, Redis queue, shared storage | Shared `N8N_ENCRYPTION_KEY` across all processes | Distributed installations |
| n8n Cloud | Console workflow backup downloads | Separate credential storage or support ticket | Cloud owners needing workflow copies |

A universal self-hosted backup interval or recovery-time guarantee is not published in n8n's documentation. Operators choose schedules based on how much workflow execution history or configuration change they can afford to lose, following standard [RPO and RTO planning principles](https://backup.mrplanb.com/rpo-vs-rto-what-is-the-difference-and-why-does-it-matter).

## Self-hosted SQLite and PostgreSQL recovery

Small self-hosted deployments typically rely on the default SQLite database inside `~/.n8n`. To avoid database corruption during a copy, n8n instructs operators to stop n8n before copying SQLite data or to use tooling that produces a consistent SQLite snapshot. Understanding [how snapshots differ from backups](https://backup.mrplanb.com/what-are-the-key-differences-between-snapshots-and-backups-and-when-should-each-be-used) helps here because a live file copy without stopping the service or using snapshot-safe tooling can capture an inconsistent file.

Larger self-hosted deployments run PostgreSQL instead of SQLite. For PostgreSQL setups, the `.n8n` folder still holds important state such as the generated encryption key if `N8N_ENCRYPTION_KEY` is unset, while PostgreSQL holds workflows, credentials, and execution data and must be backed up separately using database tooling. You must also back up your deployment configuration, environment variables, custom-node directories, and any custom filesystem paths used for binary or execution data.

In container deployments, the documented Docker setup mounts `n8n_data` at `/home/node/.n8n` for persistence. Keeping off-host copies of that volume and your database backups follows the same rules as [backing up servers to the cloud](https://backup.mrplanb.com/how-can-organizations-back-up-servers-to-the-cloud-securely-and-efficiently), protecting your automation stack if the host disk fails.

Full restoration follows four steps documented by n8n:

- Stop the running n8n instance before modifying state.
- Restore the `.n8n` folder and, for PostgreSQL setups, restore the database using database tooling.
- Restore your deployment environment variables, including `N8N_ENCRYPTION_KEY` when using a custom key.
- Start n8n and confirm that workflows and credentials load as expected.

## Server CLI workflow and credential exports

Server CLI exports provide portable supplemental copies and simplify moving workflows between instances. You can export workflows as separate readable JSON files by running `n8n export:workflow --backup --output=backups/workflows/`, and export credentials by running `n8n export:credentials --backup --output=backups/credentials/`, where `--backup` enables `--all --pretty --separate`.

When migrating to a new instance that uses a different encryption key, n8n provides `n8n export:credentials --all --decrypted --output=credentials.json` to write plaintext secrets. Docker operators run these Server CLI commands with `docker exec -u node -it <n8n-container-name> <n8n-cli-command>`. Any CLI exports written outside the persisted `/home/node/.n8n` mount require a host bind mount or must be copied out of the container before container recreation.

Restoring exported files uses `n8n import:workflow --separate --input=backups/workflows/` and `n8n import:credentials --separate --input=backups/credentials/`. Keep in mind that imports overwrite existing workflows or credentials with matching IDs. As of November 2026, the table below summarizes how CLI exports compare with full-instance backups.

| Recovery method | What it captures | What it omits | Primary use case |
| --- | --- | --- | --- |
| Full `.n8n` and database backup | Workflows, credentials, users, roles, history, settings | Unpersisted host files outside backup paths | Full disaster recovery of an instance |
| CLI encrypted export | Workflows and encrypted credential JSON files | Users, roles, history, logs, variables, settings, key | Portable backup with original key retained |
| CLI decrypted export | Workflows and plaintext credential JSON files | Users, roles, history, logs, variables, settings, key | Migration to an instance with a new key |

Because CLI workflow and credential backups exclude users, roles, execution history, logs, variables, instance settings, and the encryption key, they serve as portable supplements rather than a replacement for full `.n8n` and database backups.

## Queue-mode disaster recovery planning

Distributed installations use queue mode to scale execution across multiple worker processes. In queue mode, Redis holds pending execution IDs while workers retrieve workflow information and save results in the database, and n8n discourages using SQLite in this architecture.

Recovering a queue-mode deployment depends on keeping every component aligned. Queue workers and webhook processors must share the main instance's encryption key so each process can read stored credentials. Current queue-mode documentation defaults binary storage to the database, and if you configure filesystem storage instead, every relevant process must mount a shared volume at the exact same path.

An official Redis backup and restore procedure guaranteeing recovery of queued or in-flight executions without loss or duplication is not published in n8n's documentation. Because Redis holds pending execution IDs while PostgreSQL stores workflow definitions and results, operators planning distributed recovery should review [why Redis requires specialized backup strategies](https://backup.mrplanb.com/why-are-specialized-backup-strategies-required-for-databases-like-redis-in-cloud-native-environments) alongside their database recovery plan.

## n8n Cloud workflow backups

For n8n Cloud instances, n8n automatically creates downloadable workflow backups for instance owners. Those backups contain workflows while excluding credentials, so Cloud owners still need another way to track or re-enter sensitive connection secrets during recovery.

Cloud owners can retrieve a backup from the Cloud console by opening Export, selecting Workflow backups, and clicking Download workflows. Cloud PostgreSQL instances currently require a support ticket for workflow export because console export is unavailable for those setups. Cloud backup frequency, retention schedules, full-instance restore entitlements, and guaranteed recovery time or recovery point targets could not be confirmed from n8n's documentation.

## FAQ

### How do I set up disaster recovery for self-hosted n8n?

Back up your `.n8n` directory, your credential encryption key, any external binary or custom-node directories, and your deployment environment variables. If you use SQLite, stop n8n before copying `~/.n8n/database.sqlite` or use tooling that produces a consistent SQLite snapshot; if you use PostgreSQL, take a separate database backup with database tooling.

### What happens if I lose my n8n encryption key?

You cannot restore encrypted credentials from a database backup or an encrypted CLI credential export without the original encryption key stored in `~/.n8n` or configured in `N8N_ENCRYPTION_KEY`. If you plan to migrate credentials to an instance with a different key, export them while the original instance is running using `n8n export:credentials --all --decrypted --output=credentials.json`.

### Can I use n8n CLI exports as my only disaster recovery backup?

No, CLI workflow and credential backups exclude users, roles, execution history, logs, variables, instance settings, and the encryption key. They work well as portable copies or migration files, while full recovery requires backing up `.n8n`, your database, external storage, and environment variables.

### Do n8n Cloud workflow backups include credentials?

No, n8n Cloud's downloadable workflow backups contain workflows only and never include credentials. Cloud owners using standard instances download workflow backups through the Cloud console under Export and Workflow backups, while Cloud PostgreSQL owners must open a support ticket to request a workflow export.

Source: https://backup.mrplanb.com/n8n-disaster-recovery
