n8n backup and recovery

How to Back Up and Restore Self-Hosted n8n

A workflow export is not a full instance backup. Protect the database, encryption key, deployment configuration, and binary storage, then prove that they work together on an isolated restore.

Print shop operator backing up a workflow and database to secure storage, then restoring them to a healthy system

A recoverable self-hosted n8n backup has four core parts: the database, the original encryption key, the deployment configuration and secrets, and any binary-data storage your executions still need. Back up the persistent .n8n volume even when PostgreSQL stores the main database. n8n documents that this directory can still contain the encryption key, logs, and source-control assets.

Partner disclosure. This guide includes a partner link to n8n Cloud. If you sign up through it, FloxoLab may earn a commission at no extra cost to you.

Short answer: workflow JSON files alone are not enough. They do not recreate the complete instance state, and encrypted credentials are unusable without the key that encrypted them.

What must be in the backup

Asset Why it matters Typical location
Database Workflows, encrypted credentials, users, projects, settings, and retained execution data ~/.n8n/database.sqlite or PostgreSQL
Encryption key Decrypts the credentials stored in the database ~/.n8n settings or N8N_ENCRYPTION_KEY
Deployment config Restores database connection, public URL, proxy, timezone, pruning, and execution behavior Compose file, environment settings, secret references, proxy config
Binary data Restores retained files handled by executions when filesystem or external storage is used Persistent filesystem, database, or configured external store
Custom and community nodes Allows restored workflows to load the same node types and versions Package list, custom-node directory, container image, or build manifest

Do not put the raw encryption key, database password, OAuth secrets, or an unredacted environment file in a public repository. Keep a sanitized deployment definition in version control and protect the actual secrets in a restricted password manager, secret store, or encrypted backup.

Keep an encrypted copy of each complete backup set off the primary server, with restricted access. Generate a SHA-256 manifest for the finished files. For a set with several files, list every artifact in the manifest, including the database dump and separately stored binary data. This is a one-file example, run from the folder holding the archive:

sha256sum n8n-data-2026-07-18.tgz > SHA256SUMS
sha256sum -c SHA256SUMS

Verify the copy against a trusted manifest after transfer and before restoring. Store a trusted copy of the manifest off the primary server. A matching hash checks file integrity. A restore drill checks whether the files work together.

Choose the database path before writing the runbook

Self-hosted n8n uses SQLite by default. The database file is ~/.n8n/database.sqlite. PostgreSQL is the other supported database option. The backup and restore commands must match the database your instance actually uses.

SQLite: capture a consistent persistent volume

The simplest small-instance method is a short maintenance window: stop the n8n application, archive its persistent volume, then start it again. Stopping writes avoids treating an arbitrary live file copy as a consistent database backup. Compose may turn the logical name n8n_data into myproject_n8n_data by prefixing the project name. A volume with an explicit name: uses that name as written. Use docker inspect on the n8n container to confirm what is mounted at /home/node/.n8n. Substitute that actual volume name in this Linux example:

N8N_DATA_VOLUME=myproject_n8n_data
docker volume inspect "$N8N_DATA_VOLUME" >/dev/null || exit 1
mkdir -p backups
docker compose stop n8n
docker run --rm \
  -v "$N8N_DATA_VOLUME:/data:ro" \
  -v "$PWD/backups:/backup" \
  alpine tar czf /backup/n8n-data-2026-07-18.tgz -C /data .
docker compose start n8n

Adjust the service name if yours differs. Check that the archive command succeeded and verify the archive before marking the backup complete. If downtime is not acceptable, use a storage snapshot or SQLite-aware backup process that guarantees a consistent result. Do not assume that copying database.sqlite while executions are writing to it is safe.

PostgreSQL: use a database dump

PostgreSQL's official documentation recommends pg_dump for logical backups. A custom-format dump works with pg_restore and is practical for restoring into a fresh database. Adapt the connection values and run the tool from a host or database container that can reach PostgreSQL:

pg_dump --format=custom --file=n8n-2026-07-18.dump n8n

pg_dump captures a consistent snapshot of PostgreSQL, including binary data stored in that database. It cannot coordinate a snapshot of separately stored files or objects. If binaries live on a filesystem or in an object store, pause incoming jobs, let in-flight writes finish, and stop n8n writers and pruning. Suspend any external deletion rules that could affect the files. Keep these writes and deletions paused until the dump and binary copy or snapshots have captured the same recovery point. Use one backup ID for both. Restore them together and verify that a retained execution file opens.

Include the persistent .n8n volume, the original encryption key, and deployment, environment, and proxy settings separately.

Add native n8n exports as a second recovery layer

n8n's Server CLI can export all database entity types. Its documentation positions this tooling for backups and migrations, including moves between SQLite and PostgreSQL. Execution-history data tables are excluded by default. Set --includeExecutionHistoryDataTables=true to include them, as shown below. Omit the flag if they are outside your recovery scope. Back up execution files stored outside the database separately.

docker compose exec -T -u node n8n \
  n8n export:entities \
  --outputDir=/home/node/.n8n/cli-backup \
  --includeExecutionHistoryDataTables=true

Workflow and credential exports are also useful for selective recovery or versioned copies:

n8n export:workflow --backup --output=backups/workflows/
n8n export:credentials --backup --output=backups/credentials/

Avoid decrypted credential exports for routine backups. n8n supports a --decrypted flag for migrations to a different secret key, but the resulting files expose every sensitive value in plain text. If that exceptional path is necessary, isolate, encrypt, restrict, and delete the files after the migration.

A safe restore runbook

Restore into a private network with its own database, binary store, and Redis queue if used. Keep production DNS, proxy routing, and webhook ingress disconnected. Block outbound access to production email, payment, CRM, and other live services. Allow only the isolated dependencies required for testing. Keep the n8n server, workers, and webhook processors stopped until the restored state is ready.

  1. Record the target. Use the same n8n version first, the same database type, and compatible custom-node versions. Upgrade only after the restored instance works.
  2. Create fresh infrastructure. Prepare a new Docker volume or empty PostgreSQL database rather than clearing production.
  3. Restore the original encryption key. Put the protected N8N_ENCRYPTION_KEY or original n8n settings in place before n8n reads the restored credentials.
  4. Restore the database. Extract the stopped SQLite volume archive into the new volume, or restore the PostgreSQL dump into the new database.
  5. Restore the surrounding state. Verify SHA-256 before restoring files. Use the matching binary-data copy, required nodes, and test-only hostname and proxy settings.
  6. Unpublish before starting. Record which workflows should be published later. On n8n 2.x, use the installed-version CLI against the restored database only. Then start the isolated instance and check startup and migration logs.
  7. Verify the application. Confirm login, projects, workflows, credentials, node availability, execution history required by policy, and binary files that should still exist.
  8. Run one safe test. Use test credentials or a non-destructive workflow and confirm that a credential can decrypt and authenticate.
  9. Publish deliberately. Review which workflows should be published before switching traffic. Imported workflows can have different active-state behavior depending on the import path and deployment mode.

The n8n CLI updates publication state in the database. Before starting the restored service, verify that the CLI points to the restored database or SQLite volume. Run this only against the restored copy:

n8n unpublish:workflow --all

Keep the network isolated. Unpublishing workflows changes their publication state but does not isolate the network or remove queued work. Publish only the individual workflows you have reviewed after validation.

Restore a SQLite archive into a new volume

A new volume keeps the original recoverable while you inspect the restore. This example extracts the archive created above without deleting the production volume:

docker volume create n8n_restore_data
docker run --rm \
  -v n8n_restore_data:/data \
  -v "$PWD/backups:/backup:ro" \
  alpine tar xzf /backup/n8n-data-2026-07-18.tgz -C /data

Use a new volume name or verify that the target is empty before extracting. Set the restore Compose file to mount that actual volume, for example by declaring it external with name: n8n_restore_data. Keep production DNS and webhook routes disconnected until validation passes.

Restore PostgreSQL into a fresh database

createdb n8n_restore
pg_restore --dbname=n8n_restore n8n-2026-07-18.dump

Real deployments may need explicit host, user, role, ownership, TLS, and schema options. Test the exact command your operator will use and document it beside the backup job without embedding the password.

Choose recovery tools by what you need to restore

A larger backup-software category is not a reason to replace a focused n8n recovery plan with a generic product roundup. Choose the smallest method that can restore the required state. n8n's backup documentation, checked October 19, 2026, distinguishes a full instance backup from workflow-and-credential exports.

Recovery needMethod to evaluateEvidence to require
One damaged workflowA versioned workflow exportThe intended workflow can be imported into a disposable test instance. This is not full-instance recovery.
Complete SQLite instanceA stopped .n8n folder/volume copy or SQLite-consistent snapshotThe database and original key are present; include custom filesystem paths and deployment settings.
Complete PostgreSQL instanceDatabase-native backup plus .n8n/key and surrounding deployment stateThe database restores into a fresh target and credentials can decrypt with the original key.
Retained execution filesBackup of the configured binary/execution-data storageA retained test file opens after recovery; database records alone are insufficient when files live elsewhere.

When CLI exports run in Docker, persist their output on a mounted path or copy it out before recreating the container. A successful export inside an ephemeral directory is not a durable backup. Workflow/credential exports omit other instance state; the earlier full backup inventory still applies.

Measure an isolated restore instead of reporting backup-job success

Agree on the recovery point objective (RPO), the acceptable gap between the newest recoverable data and the incident, and the recovery time objective (RTO), the acceptable interruption duration. Measure both intervals during an isolated restore drill and compare them with the agreed targets.

  1. Record the backup identifier, application version, database type and newest recoverable application timestamp without copying secret values into the report.
  2. Start timing at the simulated interruption and stop when the agreed service checks pass. Include infrastructure preparation and manual fixes. If the drill starts after detection and response, record that it measured restoration only, not the entire outage.
  3. On an isolated target with production side effects blocked, verify login, expected workflows, credential decryption, required nodes and one retained test file. Use test credentials for any authentication check.
  4. Compare the recovery-point timestamp with the simulated incident timestamp to record potential data loss. Compare elapsed time with the agreed time budget.
  5. Record failures, manual steps, reviewer and next drill date. Keep a failed check visible even if the application starts.

Use a record with backup ID · version · recovery point · simulated incident time · restore start/end · validation results · missing data · manual steps · reviewer. This editorial update checked the current documentation. It did not include a restore test with Docker, PostgreSQL, or n8n, or measurements for RPO or RTO. For execution failures after recovery, follow the n8n debugging guide; hosting architecture belongs in the deployment case.

Restore-test checklist

Common backup failures

Mistake What breaks during recovery
Only exporting workflow JSON Users, projects, settings, retained executions, and complete credential state are not restored as one instance
Database without the original key Credentials remain encrypted but cannot be used
Copying a live SQLite file casually The backup may not represent one consistent database state
Skipping binary storage Execution records may exist while retained documents or images are missing
Restoring straight over production A bad archive or wrong configuration can remove the working recovery path
Never testing the restore Missing keys, permissions, node packages, and undocumented steps appear during the incident

Common questions

Where does Docker store self-hosted n8n data?

The n8n data mount is typically /home/node/.n8n. Compose may use a project-prefixed volume, an explicit volume name, or a host path. Inspect the actual mount before copying it.

Does exporting workflows back up credentials?

Not by itself. n8n provides separate workflow and credential export commands, plus the broader export:entities command. For same-instance disaster recovery, the database, original encryption key, config, and storage remain the stronger complete backup set.

Can I restore into a newer n8n version?

Restore the recorded version first when possible. This separates backup problems from application migrations. After the restored instance passes its checks, read the intervening release notes, take another backup, and perform the upgrade as a separate controlled change.

Sources checked

n8n partner link

Prefer a managed recovery path?

FloxoLab may earn a commission if you sign up through this link, at no extra cost to you.

Try n8n Cloud

Need the recovery path documented?

Send the database type, deployment shape, storage locations, and recovery target. We will help map a backup set and an isolated restore test without exposing production secrets.

Map the restore