Scope: This guide covers self-hosted n8n. It is an educational recovery plan, not a claim that a particular installation has been tested. Commands and features should be checked against the version you operate.
An n8n workflow can look healthy for months—until a database disk fails, an update goes wrong, or a Docker volume disappears.
Exporting a workflow JSON file is useful, but it does not mean you have backed up the whole n8n instance. A proper recovery plan must account for the database, encrypted credentials, the encryption key, settings, and any external files used by executions.
In this guide, you will learn how to define a backup scope, create workflow exports, protect the encryption key, back up SQLite or PostgreSQL, and run a safe restore test. The examples are deliberately conservative: do not run destructive restore commands against a production environment.
1. What Does a Complete n8n Backup Include?
The official n8n backup documentation distinguishes between CLI exports and a complete instance backup. The backup scope depends on how your installation stores its data.
| Component | Why it matters | Typical location |
|---|---|---|
| Workflows | Automation logic and node configuration | n8n database |
| Credentials | API access and integrations, stored encrypted | n8n database |
| Encryption key | Required to decrypt existing credentials | .n8n/config or N8N_ENCRYPTION_KEY |
| Users and projects | Ownership and permissions | n8n database |
| Execution history | Diagnostics and operational records | n8n database / configured storage |
| Instance settings | Configuration needed to run correctly | Database, environment, .n8n |
| Binary and custom data | Files used by executions and custom nodes | Filesystem or external storage |
When n8n uses SQLite, its database is typically inside the .n8n user directory. With PostgreSQL, you must back up PostgreSQL separately while preserving the .n8n directory and relevant environment configuration.

Figure 1: The main components of a complete self-hosted n8n backup.
2. Define Recovery Goals Before Choosing Tools
Two common operational measurements help define your backup schedule:
- Recovery Point Objective (RPO): how much recent data you can afford to lose.
- Recovery Time Objective (RTO): how long the service may remain unavailable while recovering.
For example, a workflow that sends low-volume internal reports may tolerate a longer recovery window than one coordinating customer orders. Your RPO should influence backup frequency; your RTO should influence how quickly a complete, tested restore can be performed.
Do not present a schedule such as “daily backups are enough” as a universal rule. Choose it based on business impact and actual data changes.
3. Export Workflows and Credentials with the n8n CLI
n8n’s Server CLI can export workflows and credentials into separate JSON files. The official backup syntax is:
n8n export:workflow --backup --output=backups/workflows/
n8n export:credentials --backup --output=backups/credentials/
The --backup option implies exporting all items into separate, human-readable files. Keep workflows and credentials in different directories.
For a Docker installation, commands run inside the container, for example:
docker exec -u node n8n n8n export:workflow --backup --output=/home/node/.n8n/exports/workflows/
docker exec -u node n8n n8n export:credentials --backup --output=/home/node/.n8n/exports/credentials/
Here n8n is an example container name. The output path is inside a persistent volume only if your deployment actually mounts /home/node/.n8n. Confirm the files exist and copy them to protected backup storage. Avoid assuming that arbitrary directories inside containers survive recreation.
Important: These JSON exports do not include users, roles, variables, execution history, instance settings, or the encryption key. They are not substitutes for a complete instance backup.
4. Protect the Credential Encryption Key
n8n encrypts saved credentials using an encryption key. By default, a generated key is stored in the n8n user folder. Installations may instead use the N8N_ENCRYPTION_KEY environment variable.
A restored database with the wrong key cannot decrypt its existing credentials. This makes the encryption key a critical part of the recovery plan.
Recommendations:
- Preserve the existing key securely and separately from publicly accessible backup files.
- Use restricted access and a secrets-management solution appropriate to your infrastructure.
- Never place the key in a public repository, tutorial screenshot, or unencrypted log.
- Record how the key is restored without copying its value into a broadly shared runbook.
- For queue mode, ensure workers use the same configured key as the main instance.
Do not generate a fresh encryption key during an otherwise valid restoration and assume old credentials will continue working.
5. Back Up SQLite Safely
SQLite is suitable for many smaller self-hosted deployments. The key risk is copying a live database file while n8n is writing to it.
n8n recommends stopping the application before copying the .n8n folder for an ordinary filesystem backup. If downtime is unacceptable, use an appropriate consistent SQLite snapshot mechanism rather than naively copying an active database file.
A simplified maintenance-window procedure is:
- Record the running n8n version and configuration.
- Stop the n8n application using your deployment’s normal procedure.
- Copy the entire persistent
.n8nfolder into protected storage. - Verify the copy, ownership and permissions.
- Restart n8n and confirm key workflows are available.
Avoid providing an unconditional docker cp command as a universal backup recipe: named volumes, bind mounts and container names vary between installations.
6. Back Up PostgreSQL with Database-Aware Tools
A PostgreSQL deployment generally needs two separate backup parts: a consistent database backup and the .n8n configuration/files.
For an illustrative PostgreSQL environment, administrators may use pg_dump:
pg_dump --format=custom --file=n8n-db.dump "$DATABASE_URL"
This example requires the PostgreSQL client, a valid connection string, appropriate privileges, and a destination with sufficient space. It is not a ready-made command for every Docker or managed PostgreSQL setup.
A successful pg_dump process alone does not verify that the archive can be restored. You should also use the database provider’s recommended backup strategy, including point-in-time recovery when your recovery objectives require it.
Never publish real connection strings or passwords in backup logs.
7. Include Files, External Storage and Configuration
A database dump does not capture every asset. Review your environment for:
- The
.n8nuser directory and itsconfigfile. - Deployment configuration and environment variables.
- External binary or execution-data storage, when configured.
- Custom-node directories and project-specific assets.
- Reverse-proxy and webhook endpoint settings required for service recovery.
Where binary files are stored outside the default location, include the actual storage path or provider in the backup plan. Do not assume every n8n plan supports every external-storage feature.
8. Follow a Consistent Backup Workflow
A trustworthy backup pipeline separates capture, protection and verification.
Stage A — Prepare: inventory data locations, select a backup window and identify the system version.
Stage B — Capture: create a consistent database backup; capture .n8n, deployment settings and any external file stores.
Stage C — Protect: encrypt archives, restrict access, store an off-site copy and apply retention rules.
Stage D — Validate: check exit codes and file size, record a manifest and periodically perform an isolated restore.

Figure 2: A backup pipeline that does more than produce a file.
A backup job that exits successfully can still produce a useless recovery artifact if a required component was omitted.
9. Apply a Sensible Retention and Storage Policy
One copy on the same server protects poorly against hardware failure or ransomware. Consider keeping multiple versions, with at least one copy protected from the main deployment’s access permissions.
For example, a small business may combine short-term daily retention with periodic longer-term snapshots. The exact number of copies and retention period should follow your data, budget and obligations.
Use encryption at rest and in transit. Test whether backup administrators can restore the files without relying on credentials stored only in the failed environment.
Be cautious about putting raw workflow exports into public Git repositories. Workflows may include internal URLs, identifiers or other operationally sensitive configuration even when credentials are encrypted separately.
10. Restore Workflow Exports Without Overwriting Production
The Server CLI includes import commands:
n8n import:workflow --separate --input=backups/workflows/
n8n import:credentials --separate --input=backups/credentials/
These are restore examples for an isolated target instance, not commands to run blindly against an active production database.
Important: n8n documents a known issue where cron triggers from previously active workflows may continue running after import in some deployments until the instance is restarted. Keep restored workflows isolated, review their trigger state, and follow the documented restart procedure before allowing production traffic.
Before importing, complete owner setup on a fresh instance, make the correct encryption key available, and confirm the target’s users or projects as appropriate.
Exports preserve item IDs. If matching IDs already exist in the target, imports can overwrite records. Imported workflows normally start deactivated, so review them carefully before allowing scheduled jobs or webhooks to execute.
11. Restore a Complete Instance
For a true disaster-recovery operation, the official high-level sequence is:
- Stop n8n.
- Restore the
.n8ndirectory and configured custom-node directories. - Restore PostgreSQL when that database is used.
- Restore deployment variables, encryption key and external-storage configuration.
- Start n8n and verify the environment.
The exact database commands depend on your database, hosting and backup format. Restoration is a change-controlled operation: it should have a runbook, approval and a rollback plan.
If you are restoring from an older backup, confirm your n8n version and migration compatibility before permitting automatic upgrades to modify the recovered database.
12. Test Recovery on an Isolated Environment
A restore drill answers the most important question: Can the system actually recover?
Use a separate host or network environment, disable public webhooks and prevent outbound actions such as customer messages, payments, or destructive API requests.
Then verify:
- The database loads and workflows appear.
- Existing credentials decrypt with the restored key.
- User permissions and required settings are present.
- Relevant custom nodes and files exist.
- No test run can cause production side effects.
- RTO and RPO assumptions match measured results.
Verify that restored credentials can be decrypted and used successfully in a controlled, non-production integration test. Seeing credential names in the interface alone does not prove that recovery was successful.

Figure 3: Test restores away from production and document every recovery gap.
Document what you learned, not just whether the test passed. A missing credential or unavailable binary file is an actionable finding.
During an isolated restore test, verify that existing credentials can be decrypted and used in a controlled, non-production integration test. Seeing credential names in the interface alone is not sufficient proof.
13. Common Backup Mistakes
Mistake 1: Only exporting workflow JSON. This misses data and settings needed for complete recovery.
Mistake 2: Losing the encryption key. Your database may be intact while credentials become unusable.
Mistake 3: Copying live SQLite files without a consistent snapshot. This can create an inconsistent backup.
Mistake 4: Backing up inside an ephemeral container only. Container recreation can destroy the files.
Mistake 5: Never trying a restore. Backup success is not the same as recovery success.
Mistake 6: Importing into production without checking IDs. Existing items may be overwritten.
Mistake 7: Triggering live actions during a restore drill. An isolated environment must prevent unwanted side effects.
14. Production Backup Checklist
- The data storage mode (SQLite or PostgreSQL) is documented.
- A consistent database backup process exists.
- The
.n8ndirectory is included. - The original encryption key is securely recoverable.
- External files and custom nodes are covered.
- Deployment configuration is captured securely.
- Backups are encrypted and access-restricted.
- A separate or off-site copy is maintained.
- Retention and deletion rules are documented.
- Backup failures trigger a notification.
- Restore commands are tested outside production.
- Expected RTO and RPO are recorded.
- The restore runbook has an owner.
15. Frequently Asked Questions
Is exporting n8n workflows the same as a full backup?
No. Workflow and credential exports are useful for migration, but do not contain all users, settings, history and configuration required to recreate a full instance.
Can I restore encrypted credentials without the original encryption key?
Normally you need the same encryption key. The CLI also supports a decrypted credentials export, but that produces highly sensitive plaintext and should not be used casually.
Does the backup process differ for SQLite and PostgreSQL?
Yes. SQLite is commonly stored inside .n8n, while PostgreSQL needs its own database backup in addition to the n8n user folder and configuration.
Should I put backups in Google Drive or S3?
An appropriate encrypted off-site store can be useful, but choose one with suitable access controls, retention and restore procedures. The storage destination does not replace the need for a consistent database snapshot.
Can I restore n8n without stopping it?
Some database systems support consistent online backup methods, but a complete restore typically requires controlling application access and avoiding concurrent writes. Follow the relevant database and n8n procedures.
How often should I test a restore?
Set a recurring schedule consistent with the importance of the automations and your RTO/RPO. A major upgrade or infrastructure change is also a reason to re-test recovery.
16. Final Thoughts
Backups are not primarily about producing files. They are about preserving the ability to operate when something fails.
For n8n, the practical minimum is to understand the database, protect the original encryption key, retain configuration and external files, and prove recovery in a safe environment.
A backup you have never restored is a recovery assumption—not a recovery result.
Continue Reading
- How to Build Reliable n8n Workflows: Error Handling, Retries, and Duplicate Prevention — Make individual workflow executions easier to recover.
- How to Scale n8n Workflows with Queue Mode, Workers, and Concurrency Limits (2026 Guide) — Understand additional components in distributed deployments.
- How to Secure n8n Webhooks: Authentication, Signature Verification, and Replay Protection — Harden the entry points restored workflows expose.
Official Technical References
- n8n — Back up and restore
- n8n — Use the command line
- n8n — Set a custom encryption key
- n8n — Docker installation
Technical disclosure: The commands and recovery design are illustrative and were not executed against a live n8n deployment. Adapt them to your version, hosting environment and data-retention requirements; validate all restores in an isolated environment.






