Use this powerful n8n workflow to automatically backup all your decrypted n8n credentials to GitHub. Protect your data using this reliable n8n templates solution.
Download this n8n workflow template and start using it instantly.
Securing your credentials is paramount for maintaining a highly available n8n instance. This solution provides a reliable, automated way to protect your configuration data. By leveraging command line execution and complex scripting within an n8n node structure, this n8n workflow decrypts and exports all credentials periodically (every two hours by default). Crucially, the automation uses version control logic: it only updates files on GitHub if a difference is detected, ensuring a clean commit history.
This advanced n8n workflow utilizes a self-calling subworkflow pattern to process each credential individually, optimizing memory usage and scalability, making it one of the most essential n8n templates for self-hosting users who require robust data backup.
npx n8n export:credentials --all --decrypted to gather all sensitive credential data.{ID}.json).isDiffOrNew executes sophisticated comparison logic: it decodes the existing GitHub JSON (if present), orders the keys of both the old and new JSON objects to ensure reliable comparison, and determines if the current n8n credential data is "same", "different", or "new."Get file data, Create new file, Edit existing file). Ensure this account has push permissions to the target repository.Globals Set n8n node (located around the start of the subworkflow). Update the values:repo.owner: Your GitHub username.repo.name: The name of your repository.repo.path: The folder path where backups will be stored (e.g., credentials/).npx n8n command can be executed. Schedule Trigger / On clicking 'execute': The n8n trigger points for the automation. The Schedule Trigger runs the backup routinely every two hours.
Execute Command: Executes the shell command npx n8n export:credentials --all --decrypted to retrieve all currently configured, decrypted n8n credential JSON data.
JSON formatting (Code n8n node): Handles the complex task of parsing the large raw output from the shell command, which contains all credentials, and separates them into distinct data items for the subsequent n8n node loops.
Execute Workflow: A crucial flow control n8n node that calls the current n8n workflow recursively, initiating the subworkflow execution for each individual credential item.
Globals (Set n8n node): Stores configuration variables, including the target repo.owner, repo.name, and repo.path for the GitHub operations. This node must be edited during setup.
Get file data (GitHub n8n node): Attempts to fetch the existing backup file from GitHub, using the unique credential ID as the filename. It is configured to run even if the file is not found (using continueOnFail) to handle new credentials.
isDiffOrNew (Code n8n node): This advanced scripting n8n node performs the core comparison logic. It reliably determines if the current credential JSON differs from the backed-up version by standardizing (ordering) the JSON keys before performing a string comparison, setting the githubstatus property.
Check Status (Switch n8n node): Directs the flow based on the githubstatus output. This ensures that the GitHub API is only called to commit changes when the data is truly different or new.
Automate robust version control for your n8n instances. This n8n workflow uses an n8n trigger to fetch all active n8n templates and back them up securely to GitHub, ensuring data integrity and easy rollback.

Use this robust n8n workflow to automatically backup and version your production n8n workflows to a secondary n8n instance using the n8n API. Includes rolling retention and Notion tracking.

Use this robust n8n workflow to automatically backup all your existing n8n workflow designs daily to Google Drive. This n8n template ensures essential system redundancy and disaster recovery.

Use this powerful n8n workflow to automatically backup all your n8n workflows to GitHub, ensuring version control and history. Features dynamic pathing and efficient difference checking.

Freelance consultant from Brazil, specializing in automations and data analysis. I work with select clients, addressing their toughest projects. For business inquiries, email me at [email protected] or message me on Telegram for a faster response.







































