Updating n8n without data loss: version pinning, backup, rollback
How to update n8n safely: version pinning, backup of database and encryption key, the right approach.
If you lose the n8n encryption key, all stored credentials become unusable. Here is how to back up workflows, credentials, and keys correctly.
An n8n backup is only complete when it secures workflows, credentials, and the matching encryption key together. If the key is missing or differs from the original, n8n can no longer decrypt stored credentials, and every saved connection to an email inbox, CRM, or API must be set up again by hand. Workflows themselves can be exported and imported as JSON via the web interface or the CLI; credentials additionally require the original encryption key or a deliberately decrypted export. For companies that self-host n8n and are responsible for their automations, the encryption key is therefore the single most important building block of a working backup strategy. As of: July 2026.
The encryption key encrypts all credentials stored in n8n before they are saved in the database; without the matching key, this data remains permanently unreadable. On first launch, n8n automatically generates a random key and stores it in the ~/.n8n folder. Anyone who wants to use their own key instead must set the N8N_ENCRYPTION_KEY environment variable before the settings file is created; a later change is not applied automatically. If n8n runs in queue mode with multiple workers, the same encryption key must be set for each individual worker according to the documentation (n8n documentation on the encryption key).
If the encryption key is lost or differs from the one originally used to encrypt the credentials, n8n reports that the credentials could not be decrypted because a different encryption key was presumably used. The workflow logic itself remains intact as a JSON structure, but every stored credential such as API keys, OAuth tokens, or SMTP access becomes unusable and must be reconnected manually. With just a few workflows this is annoying; with grown automations that have many connections to accounting, CRM, or inventory management systems, it effectively means starting the entire credential management from scratch. The encryption key therefore belongs in every backup routine, separate from, but just as reliable as, the database backup itself.
For backups, n8n offers ways both through the interface and through the server CLI; for regular backups, the CLI is the more reliable route. In the web interface, a workflow can be downloaded as a JSON file via the three-dot menu, or imported from a file or a URL.
Details on all commands can be found in the n8n documentation on export and import as well as on the command line (Export and import in n8n, n8n CLI commands).
Changing the encryption key is not a routine operation but an intervention that can lead to permanent data loss without a prepared backup. n8n distinguishes between the instance encryption key, which as the master key never changes, and an underlying data encryption key, which actually encrypts the credentials and can be renewed via its own rotation function. According to the documentation, this rotation is explicitly not reversible; if the associated function is disabled again, all data encrypted since then becomes permanently inaccessible, a complete database backup beforehand being the only safeguard (n8n documentation on key rotation). Caution is also advised when sharing exported workflow JSONs, as the files contain credential names and IDs, and HTTP request nodes imported from cURL can even contain authentication headers in plain text. This information should be removed before any handover.
Anyone who operates their own n8n instance and needs support setting up backup routines or migrating between servers will find guidance in the n8n offering from NordFlux.
No, a plain database backup does secure workflows and encrypted credentials, but without the associated encryption key, these credentials remain unreadable upon restore. By default, the key is located in a separate settings file in the ~/.n8n folder and must therefore be deliberately backed up as well, ideally separately from the database backup in an access-protected location.
Yes, exporting a workflow via the interface or with n8n export:workflow contains only the workflow structure with references to credential names and IDs, not the credentials themselves. To take the credentials along as well, a separate export with n8n export:credentials is required, and the destination must either have the same encryption key, or the credentials must first be exported in plain text using the --decrypted option.
The most reliable way is the decrypted export with n8n export:credentials --all --decrypted on the source instance, followed by the regular import on the destination instance, which automatically re-encrypts the data with its own encryption key. Since the file is briefly in plain text during this process, it should be securely deleted immediately after the import.
Without the original key or a backup of the settings file, already encrypted credentials can no longer be recovered; every affected connection must be manually re-authenticated in the respective workflows. The workflow logic itself is not lost in the process; the effort is limited to re-entering the credentials, which can nonetheless mean several hours of work for extensive automations.
Founder of NordFlux. Spent four years automating processes at enterprise scale at Dräger, and now brings that depth to the mid-market — pragmatic and with full data sovereignty.
Certifications
How to update n8n safely: version pinning, backup of database and encryption key, the right approach.
How to set up Anthropic and OpenAI credentials in n8n, choose the right model for each task, and keep token costs under control.
Export workflows, recreate credentials, adjust webhook URLs: here is how the move from n8n Cloud to self-hosted succeeds.
A backup without the encryption key only fails when it matters most, with credentials that can no longer be decrypted. NordFlux sets up backups for your n8n instance that cover workflows, credentials and the key together, and rehearses the restore regularly. That turns hoping the backup works into a reliable recovery plan.