Backing up a self-hosted n8n instance: what teams must protect first
A self-hosted n8n instance keeps its state in several places at once: workflow definitions and execution data in the database, credentials encrypted with the instance encryption key, binary data such as files processed by workflows, and any custom nodes installed on the host. A backup is only useful if these pieces are captured together and tested. A database dump without the matching encryption key leaves stored credentials unreadable, and a restored instance missing its custom nodes will fail on workflows that depend on them. Treat the .n8n folder and its encryption key, the PostgreSQL dump, the binary data store and the custom node code as one backup set, with a recorded point in time for each.
Teams need this work before go-live, after every n8n upgrade, before moving the instance to new hosts, and before changing the database or storage layout. Each of these events can leave the instance in a state that the previous backup does not match. In queue mode, the encryption key must also be identical on every worker and webhook processor, so the key you protect is the same key the whole deployment depends on. Confirm which storage backend your instance uses for binary data, where the encryption key is stored, and who holds copies of it before you decide on a backup design. Those answers determine what must be encrypted, where copies live and who can restore them.
Plan the restore before you need it. A restore rehearsal on a separate host shows whether the encryption key matches the database, whether workflows and credentials load, and whether binary data resolves to the right files. For the database layer, PostgreSQL offers continuous archiving and point-in-time recovery, which teams should evaluate alongside plain dumps. Ask your implementation partner or internal DBA to document the expected restore time and the steps in writing, and to measure them in a rehearsal in your own environment. Recovery targets should come from your own risk decisions, not from defaults.
Which parts make up a complete n8n backup
An n8n instance is spread across several stores that do not reproduce each other. The database holds workflows and encrypted credentials, the .n8n folder holds the key that unlocks those credentials, and the binary and custom node locations hold data and code that the database only refers to. Back up all of them together, from the same point in time, or the restore will be incomplete.
The .n8n folder and encryption key
The .n8n folder holds the instance configuration and the encryption key that n8n uses to encrypt credentials before storing them in the database. Without that key, a database dump contains credential records that cannot be decrypted, so every API token and password in your workflows would need to be re-entered by hand. Store the key in a separate, access-controlled location from the backup, and confirm that the restored instance starts with the same key value before you import anything.
PostgreSQL dumps
The PostgreSQL database holds workflow definitions, execution records, users, projects and the encrypted credential rows. Take logical dumps with pg_dump or run continuous archiving, so you can restore to a chosen point in time. A dump taken without the matching encryption key can be restored, but the credentials it contains will not work. Test restores on a separate server, since a backup that has never been restored is unproven.
Binary data stores
When binary data mode stores files outside the database, workflow executions that handle attachments, images or exported documents keep those files on disk or in object storage. The database holds only references to them, so a database restore without these files leaves broken links to data that no longer exists. Confirm where your instance writes binary data, include that location in the backup job, and check that its snapshots line up with the database dump.
Custom nodes and extensions
Private community nodes, Code node modules and any external hook files live in the instance file system, not in the database. Workflows that call them fail after a restore if the packages are missing or at different versions. Record the installed package names and versions, keep them in version control or in your artifact store, and rebuild the environment from that record during a restore test.
CLI export as a secondary copy
The n8n Server CLI can export workflows and credentials to files. This export is useful as a second copy of workflow logic, for review or for moving single items between instances. It does not replace the full backup, because it does not capture execution history, instance settings or the complete database state, and exported credentials remain tied to the key that encrypted them. Treat it as a supplement to the database and key backups, and confirm the export format with your n8n version before relying on it.
How the backup parts fit together
The backup starts on the main n8n instance and the PostgreSQL database, which hold workflows, execution data and encrypted credentials. The .n8n folder carries the encryption key, without which stored credentials cannot be decrypted, so it is marked as trust-critical alongside the database. Binary data stores and custom nodes are copied as separate parts, and all of them flow into one backup repository. Before relying on the set, confirm that a restore target can reach every part and that the key matches the one that encrypted the database.
Backup parts from a running n8n instance flow into one repository and then into a restore target.
How to back up n8n and restore it step by step
This sequence captures the n8n configuration, encryption key, database, binary data and custom nodes as one consistent set, then proves that the set can be read back. The result is a verified restic snapshot that a second environment can restore from.
Pause workflow writes before the snapshot
Before dumping anything, stop or drain active writes so the database and the file folders describe the same moment. For a single instance, stop the n8n container or process, or put a maintenance window in place and confirm no executions are running. In queue mode, stop the main instance, webhook processors and workers together. Confirm the stop by checking that the process is down and that no new rows appear in the execution tables during the dump. Ask your n8n administrator to confirm how your deployment handles in-flight executions before you rely on this step.
Dump the PostgreSQL database
Run a logical dump of the database that holds workflows, credentials (encrypted), executions and settings. Use
pg_dumpwith a custom format so the file can be restored selectively, for examplepg_dump -Fc -f n8n.dump n8n, using the database name and credentials from your environment. Record the PostgreSQL server version alongside the file, because restores depend on it. The step is done when the dump file exists, is not empty, andpg_restore --list n8n.dumpprints a table of contents without errors.Copy the .n8n folder and encryption key
Copy the n8n data folder, usually
.n8n, including its configuration file, and record the value of the encryption key in a separate secure store. Credentials in the database cannot be decrypted without that key, so a database dump with no key is incomplete. Keep the key out of the same unencrypted location as the dump. The step is done when the key you stored matches the key the running instance reads, which you can confirm by checking that the key is set in the environment or configuration of the instance you restore to later.Capture binary data and custom nodes
Copy the binary data store if your instance keeps files outside the database, and copy any custom nodes or community packages installed under the n8n folder or your container image. Binary data often lives on a local disk or object storage, so confirm the storage location for your setup. Record the installed package versions. The step is done when a file listing of the binary store and the custom node directory matches what the workflows reference, and the package list is saved with the backup.
Optional: export workflows and credentials with the CLI
Run the n8n Server CLI export as a secondary copy of workflows and credentials. This copy is useful for reviewing or moving individual items, but it does not replace the database dump and encryption key. Store the export with the same protection as the other artifacts, because exported credentials remain sensitive. The step is done when the export files open and list the expected workflow count and names.
Store the set in an encrypted restic repository
Back up the dump, the folder copy, binary data, custom nodes and the CLI export into one restic repository. restic encrypts all repository data with AES-256 in counter mode and authenticates it with a Poly1305-AES message authentication code, so the repository can sit on local disk, SFTP, S3-compatible storage or another supported backend. Initialize it with
restic init, then runrestic backupwith the staging paths. Each run creates a snapshot. The step is done whenrestic snapshotslists the new snapshot ID and the paths it covers. Resume the n8n processes after this step.Restore the set in dependency order
Restore to a separate environment in this order: first the restic snapshot to a staging folder with
restic restore <snapshot-ID>, then the PostgreSQL database withpg_restore, then the .n8n folder, binary data and custom nodes, and finally start n8n with the same encryption key. Restoring the database before the key or files can leave credentials unreadable. The step is done when n8n starts, the workflow list matches the source, and one credential opens in the editor without a decryption error.Verify the repository with restic check
Run
restic checkregularly to confirm snapshots, trees and pack files are structurally consistent. For a full verification, runrestic check --read-data, which reads pack files back to confirm stored data is unmodified, or use--read-data-subsetto spread that cost across runs. Schedule these checks and keep their output. The step is done when the check exits without errors, and a test restore of at least one recent snapshot completes and passes the n8n start test above. Document the schedule with your operations team.
Choosing a restic storage target for n8n backups
A local directory target writes the restic repository to a disk or mounted volume that the backup job can reach directly. The data stays on hardware you already control, and no network path or remote service sits between the backup and the repository. The trade-off is that a copy on the same host or in the same rack protects against corruption and accidental deletion, but it does little against losing the server, the site or the disk array itself.
- Control: Only the people with operating system access to the host and the volume can read or change the repository.
- Residency: Data stays where the host is located, which makes location questions simple to answer.
- Failure scope: A host failure, fire or ransomware on the same machine can take the n8n data and the backup together.
- Setup: No separate service is needed, so there is little to operate beyond disk space and permissions.
- Use: It works well as a first, fast copy, with a second target holding an off-host copy.
Confirm that the volume is separate from the n8n data disks and that the repository directory has permissions limited to the backup account.
An SFTP target stores the repository on a remote host reached over SSH, which most organizations already run and monitor. Access is controlled by SSH keys and host accounts, so the backup operator can work within existing identity and access processes. The repository still lives on a machine someone administers, so the backup host and the storage host share a trust boundary to be reviewed.
- Control: The storage administrator controls the host, and a dedicated account can be limited to the backup path.
- Residency: The data sits wherever that host runs, which can be a separate site or a different data center from n8n.
- Credentials: Store the SSH private key with restricted file permissions, and use a key dedicated to backups.
- Separation: A host that is also used for other purposes widens who can reach the repository.
- Cost: The storage host and its disks are usually existing infrastructure, so the cost is mostly in administration and capacity.
Confirm which team administers the SFTP host, who holds its root access and where its disks and backups are located.
restic can write to an HTTP REST server, which is the rest-server project that restic supports natively. It gives you a backup endpoint you run yourself, with its own access controls and no need to grant shell access to the storage machine. Because the server is a network service, it needs TLS, authentication and firewall rules like any other internal application.
- Control: You run the service and decide which clients can write, and the repository can sit on storage you choose.
- Isolation: The backup client does not need an interactive login on the storage host, which reduces the reach of a compromised n8n server.
- Exposure: Publish the endpoint only on a restricted network, and terminate TLS with certificates from your own authority.
- Operations: Someone must patch, monitor and back up the rest-server host, which adds a service to run.
- Fit: Teams that want a dedicated backup service on their own network often choose this over general file access.
Confirm the service's authentication model, its TLS configuration and where its storage volume is physically located.
restic supports Amazon S3 and S3-compatible object storage, which includes self-hosted object stores as well as public cloud buckets. Object storage suits off-site copies and retention at scale, and it separates the backup store from the n8n host. Who controls the data depends on whether the bucket is in a provider you contract with or in an object store you operate inside your own infrastructure.
- Control: Access is granted through access keys and bucket policies, so key scope and rotation need an owner.
- Residency: Confirm the region or the physical location of the bucket and any replication targets before choosing it.
- Independence: A bucket in a different account or provider keeps the backup available when the n8n environment is compromised, if credentials are kept separate.
- Cost drivers: Stored volume, request counts and data transfer are the usual charges, so deduplication and retention settings affect the bill.
- Self-hosted option: S3-compatible software run in your own data center keeps the bucket inside your controls, and it must be tested with restic before use.
Confirm the bucket location, provider sub-processors, encryption at rest settings and the people who can administer the access keys.
restic also reaches OpenStack Swift, Backblaze B2, Azure Blob Storage and Google Cloud Storage, and many other services through rclone. These options matter when your organization already standardizes on one of these platforms. Each one adds a provider relationship with its own identity model, region options and pricing, so the decision is mostly about existing contracts and residency commitments.
- Existing platform: Reusing a storage service your team already governs usually shortens access reviews and logging setup.
- Indirect support: Services reached through rclone depend on that bridge, so test restores after every change to the remote configuration.
- Provider terms: Check retention, deletion and data location terms in the contract, since restic cannot enforce them.
- Platform spread: restic runs on Linux, macOS and Windows, so the client side fits common server estates.
- Verification: Whatever target you choose, run restic check periodically and restore a sample to confirm the repository is usable.
Confirm that the provider's regions and sub-processors meet your data residency rules before the first backup is written.
Backup options and when each fits
This table compares four ways to protect a self-hosted n8n instance: the full stack backup, the CLI export, PostgreSQL continuous archiving and a read-only replica. Read each row against your recovery goal, since no single option covers everything an n8n instance holds. For most teams the takeaway is that the full stack backup is the baseline, and the other options add recovery granularity or a secondary copy.
| Approach | What it captures | What it misses | When it fits |
|---|---|---|---|
| Full stack backup (.n8n folder and PostgreSQL dump) | The .n8n folder with the encryption key, a PostgreSQL dump of workflows, executions and credentials, and binary data stores when they live outside the database | Custom nodes installed outside the .n8n folder, container images, reverse proxy and certificate settings, and anything changed after the dump was taken | The baseline for every production instance that needs a complete, restorable copy |
| CLI export as a secondary copy | Workflows and credentials exported through the n8n Server CLI, readable outside the database | Execution history, binary data, settings and the encryption key needed to decrypt credentials unless backed up separately | A portable second copy of workflow definitions for review or migration, not a sole recovery source |
| PostgreSQL continuous archiving for point-in-time recovery | Write-ahead log archives that let the database return to a chosen moment between base backups | The .n8n folder, the encryption key, binary files and custom nodes, which the database archive does not contain | Teams that need to recover to a time before a bad change or deletion, alongside a full stack backup |
| Read-only replica | A hot standby that receives changes from the primary and can serve read-only queries | Accidental deletes or corruption, which replicate to the standby, and it is not a backup on its own | Reporting or read load offload, or faster failover support when paired with external failover tooling |
| Restore test | A restore into a separate environment that proves the chosen backup set starts and decrypts credentials | Nothing in the backup itself, so it only shows the backup works if the test is run | Every option above, run on a schedule your team can evidence to auditors |
Matching PostgreSQL versions and upgrades during restore
A restore only succeeds if the target PostgreSQL server is a version the backup can be loaded into and still receives security fixes, so check both before you touch production. The PostgreSQL project supports major versions 14 through 18. Version 18 was first released on September 25, 2025, and receives support until November 14, 2030. Version 17 is supported until November 8, 2029, version 16 until November 9, 2028, and version 15 until November 11, 2027. Version 14 is supported until November 12, 2026. Versions 13 and earlier no longer receive fixes. Confirm in the n8n documentation which PostgreSQL versions your n8n release supports, and record the version of the server that wrote each backup. The PostgreSQL versioning policy sets out these dates and the release cadence.
Minor updates and major upgrades follow different procedures. A minor update, such as moving from one 17.x release to a later 17.x release, replaces the server executables and restarts the service. Minor releases never change the internal storage format, so a backup taken on one minor release restores cleanly into another within the same major version. A major upgrade changes the storage format and needs a planned route. The three documented options are a pg_dumpall export loaded into the new version, pg_upgrade, which converts the existing data directory in place, and logical replication, which works between major versions and can limit downtime to several seconds. Version 18's pg_upgrade keeps planner statistics, adds parallel jobs and offers a --swap option. Choose the route based on how much downtime your n8n users can accept and how large the database is.
Version 14 reaches end of support on November 12, 2026, so any n8n instance still on it needs a dated move to a supported major version. Treat the first restore onto the new version as a rehearsal. Load a recent backup into a staging server running the target version, start n8n against that database, and confirm that workflows, credentials and executions appear as expected. Record how long the restore and the n8n startup took, since that measurement shapes the downtime you can promise. Then schedule the production upgrade with a fresh backup taken immediately before the cutover, and keep the old server available until the new one has run through a full business cycle. The PostgreSQL upgrading documentation describes each route in detail.
Security and operational risks in n8n backups
A backup of n8n is only as safe as the material inside it. The archive holds the encryption key, stored credentials, workflow data and database contents, so it needs the same protection as the live instance. The cards below cover the failure modes that matter most and the controls to apply before a backup job goes into production.
Key copies expose every credential
The encryption key in the .n8n folder decrypts every credential stored in the database. Anyone who holds a backup copy of that key and a database dump can read every API token and password n8n uses. Restrict who can read the key file in each backup, keep the key out of general-purpose backup catalogs, and confirm that access to the key is logged. Treat the key as a secret with its own owner and rotation process.
Unencrypted dumps in transit
PostgreSQL dumps and binary data archives contain workflow definitions, execution data and credential rows. Copying them over plain network paths or to storage without transport encryption exposes that content to anyone on the path. Confirm that every transfer uses an encrypted channel, such as SFTP or HTTPS to the repository, and that the database connection itself requires encryption and a current authentication method.
Unencrypted dumps at rest
A dump file sitting on a shared volume is as sensitive as the live database. Check whether the backup target encrypts repository data at rest. restic encrypts everything it writes to a repository with AES-256 and authenticates it, so the repository is protected even when the storage provider cannot read it. If you use a different tool, confirm the same property before relying on it.
Restores that revive revoked credentials
A restore returns the database to the state of the snapshot. If a credential was rotated or revoked after that snapshot, the restored instance can bring the old secret back into use. Before reopening a restored instance, compare its credentials with the current secret inventory, rotate anything exposed since the snapshot, and disable workflows that call external systems until the review is complete.
Backups kept on the instance host
A backup stored on the same host, disk or volume as the n8n instance disappears with that host. A ransomware event, a failed disk or an accidental deletion can remove the live data and the backups together. Send copies to a separate system with separate credentials, and keep at least one copy that the n8n host cannot delete. Confirm this with the storage owner rather than assuming the cloud account or NAS protects it.
Shared backup and database credentials
When the backup job uses the same database account, cloud key or repository password as the application, a compromise of one exposes the other. Create a dedicated PostgreSQL role for dumps with only the privileges it needs, and a separate repository password and storage key for the backup job. For PostgreSQL logins, prefer SCRAM-SHA-256 over the deprecated MD5 method, and review the pg_hba.conf rules for the backup role.
Questions teams ask before backing up or restoring n8n
How much does it cost to back up a self-hosted n8n instance?
No supplied figure gives a price for backup storage or the work to set it up, so confirm those numbers with your own environment and vendors. The cost has four parts: the storage target (local disk, an SFTP host, or object storage such as Amazon S3 or Backblaze B2), the retention period, the number of environments that each need their own backups, and how often you run restore tests. Storage is a recurring cost that grows with retention. Setup and restore testing are mostly one-time or periodic labor. Restic supports many of these targets natively and deduplicates data, so storage growth is usually lower than the raw data size. Ask any partner for a written quote that lists each target, retention rule, test frequency and environment count separately.
How long does it take to restore an n8n instance from backup?
Restore time depends on the size of the PostgreSQL dump, the volume of binary data, the speed of your storage target and how many steps your team has rehearsed. Confirm the timings by running a restore into a test environment that matches production, because no supplied figure gives a duration. Time the steps separately: fetching the snapshot, restoring the database, restoring the .n8n folder with the encryption key, restoring binary data, and checking that workflows and credentials load. The first restore is usually the slowest because the team is learning the sequence. Record the measured time and repeat the test on a schedule so the estimate stays accurate as the instance grows.
What does a backup and restore project need from our team?
Your team needs to supply access and decisions, not only approvals. Plan for these inputs before work begins:
- Access to the n8n host, the PostgreSQL server, and the storage target, with the right to create and read backups
- A named owner for the encryption key and for the decision on where copies are stored
- Retention and recovery targets agreed by the business owners of the workflows
- A window in which a restore can be tested without touching production
- Someone who can confirm that restored workflows call the right external systems
Without these, a backup job can run successfully for months while nobody knows whether it can restore an instance.
Can our own team back up and restore n8n without a partner?
Yes, a team with Linux, PostgreSQL and container skills can build and test a backup process, provided it covers every component. A complete backup includes the .n8n folder with the encryption key, PostgreSQL dumps, binary data stores, custom nodes, and optionally a CLI export as a secondary copy. The main risks for in-house teams are missing one component, not testing restores, and not separating the encryption key from the database copy. A partner is most useful when you need a documented runbook, a restore test in a separate environment, or help with queue mode, where workers need the same encryption key. Decide based on the skills you already have and the recovery targets your business owners set.
Is backing up only the n8n encryption key enough?
No. The encryption key alone cannot recover workflows, executions, or credentials, because those records live in the database and the .n8n folder. A key without the matching database is useless, and a database without its key leaves stored credentials unreadable. Keep the key in a secure, separate location with restricted access, and back it up together with the database dump and the .n8n folder as one recoverable set. In queue mode, the same key must be available to every worker and webhook processor, so a restore needs the key on each node. Test that the restored instance can open a credential before you treat the backup as usable.
How often should we test an n8n restore, and what does a test prove?
Test restores on a schedule your recovery targets require, and after any change to the database version, storage target or n8n release. A useful test restores into a separate environment, starts n8n, confirms that workflows, credentials and binary data are present, and runs one workflow that reaches an external system. Restic's restic check verifies the structure of snapshots, trees and pack files, and restic check --read-data reads pack files back to confirm the stored data is unmodified. Those checks prove the repository is intact, but only a restore into n8n proves the instance works. Record each test result, the time taken, and any gaps found.
Does the backup process change when we run several n8n environments?
Yes, each environment needs its own backup set, retention rule and restore test, because each has its own database, encryption key and binary data. Development, staging and production often differ in size and in how strictly data must be protected, so their backup targets and retention may differ too. Multiply the storage and test effort by the number of environments, and check whether any environment holds copies of production credentials. Ask your partner or internal team to list each environment, its backup target and its test schedule in the quote or runbook. Confirm how any Git-backed environments are handled, since workflow definitions in Git are not a substitute for a database backup.
How DeployOpen scopes and delivers n8n backup and restore work
DeployOpen plans and implements backup and restore for n8n on infrastructure you control, starting from a written scope that names every component the instance depends on. The work covers the encryption key, the database, binary data, custom nodes and a CLI export, and ends with a restore you have tested yourself.
How we scope
- Inventory every n8n component: the .n8n folder, encryption key, PostgreSQL database, binary data store and custom nodes.
- Confirm whether the instance runs in queue mode, since workers must share the main instance's encryption key.
- Agree in writing the recovery targets, retention periods, storage locations and who holds the encryption key.
How we build
- Configure scheduled PostgreSQL dumps or continuous archiving, matched to the PostgreSQL version your platform runs.
- Set up a restic repository on storage you choose, with encryption, deduplication and access separated from the n8n host.
- Script the CLI export as a secondary copy and document how each piece is captured, stored and rotated.
How we hand over
- Deliver a runbook covering each backup job, its schedule, its location and the order of components during a restore.
- Run a restore into a separate environment and record the steps, timings and any gaps your team needs to close.
- Train your operators to run restic restore by snapshot ID and to run periodic restic check commands, including full data reads.
How we support
- Engagements are fixed-scope, with deliverables and timelines agreed in writing before work starts.
- Ongoing support, upgrades and continuous testing, including scheduled restore drills, are available as a retainer.
- Ask any partner to confirm how they will test restores, who holds the encryption key and where backups are stored.

