HeadlinesBriefing favicon HeadlinesBriefing.com

Kubernetes n8n Backup Strategy

DEV Community •
×

Data loss is a disaster waiting to happen. This guide implements a robust, atomic backup strategy for n8n workflows, credentials, Redis queues, and custom nodes. The architecture uses a Hybrid Modular V3 approach to solve race conditions and cross-namespace issues. It relies on a central backup PVC for Postgres and Redis, while N8N handles direct uploads to avoid complex RBAC permissions.

You first prepare secrets in both the `backup` and `prod` namespaces. This involves configuring Rclone for Mega.nz storage and creating an optional GPG encryption secret for sensitive data. A dedicated `backup` namespace and PersistentVolumeClaim are established to hold the staging and ready files before they are synced off-site.

Three main jobs automate the process. The Postgres job dumps data to staging, encrypts it, and moves it to the ready directory. The Redis job uses BGSAVE to copy the RDB file without blocking the service. Finally, the N8N job runs directly in the `prod` namespace, compressing the `.n8n` folder and uploading it straight to Mega.nz to ensure separate retention.

A central sync job uploads the verified Postgres and Redis backups to Mega.nz, enforcing a Dual Retention policy of 7 days locally and 15 days in the cloud. For disaster recovery, the guide details restore procedures for all three components. This ensures you can quickly decrypt and restore databases or swap out Redis and N8N volumes to recover from a total cluster failure.