Backup n8n Credentials to GitHub Automatically

This workflow automates backing up all n8n instance credentials securely to GitHub. It saves time by running scheduled exports, comparing with existing backups, and updating or creating files only when necessary.
github
executeCommand
code
+12
Workflow Identifier: 2063
NODES in Use: ManualTrigger, StickyNote, Set, HttpRequest, If, Merge, Code, Switch, NoOp, GitHub, SplitInBatches, ScheduleTrigger, ExecuteCommand, ExecuteWorkflow, ExecuteWorkflowTrigger

Press CTRL+F5 if the workflow didn't load.

Learn how to Build this Workflow with AI:

Visit through Desktop for Best experience

What This Workflow Does

This workflow backs up all your n8n credentials automatically to a GitHub repository.

It solves the problem of manually exporting credentials every week and losing data by mistake.

The result is a secure, versioned backup stored on GitHub, updated only when changes happen.

It can run manually or every two hours on a schedule to keep backups fresh.


Who Should Use This Workflow

This workflow is for people who use n8n and want to save their credentials safely without extra manual work.

It works well if you manage many credentials or want to avoid data loss due to accidents.

You also need access to a GitHub repo where backups will be stored.


Tools and Services Used

  • n8n Execute Command node: Runs the shell command to export decrypted credentials.
  • GitHub Node: Reads and writes credential backup files in the GitHub repository.
  • Code Node: Parses JSON output and compares existing and new backups.
  • SplitInBatches Node: Loops through each credential item efficiently.
  • HTTP Request Node: Fetches raw file content if GitHub file is too large to fetch normally.

How the Workflow Works (Inputs → Processing → Output)

Inputs

  • Manual or scheduled trigger to start the backup.
  • Shell command output from npx n8n export:credentials --all --decrypted.
  • GitHub personal access token and repo details.

Processing Steps

  • Run shell command to export all credentials in decrypted JSON format.
  • Extract and beautify the JSON data using a Code node.
  • Split the list into batches for manageable processing.
  • For each credential, try to get existing backup file data from GitHub.
  • If file is missing or too large, retrieve raw content using HTTP Request.
  • Compare new exported JSON with existing backup after sorting keys.
  • Decide if the backup file is new, changed, or unchanged.
  • If new, create a new file in GitHub. If changed, update existing file. If unchanged, skip commit.

Output

Updated or created credential backup files in the GitHub repository saved under specified folder.

Logs showing which credentials were processed and whether files were created, edited, or unchanged.


Beginner Step-by-Step: How to Use This Workflow in n8n

1. Importing the Workflow

  1. Download the workflow file using the Download button on this page.
  2. Inside the n8n editor, click on “Import from File” and select the downloaded workflow.

2. Configuring Credentials

  1. Add your personal access token credentials for GitHub in the GitHub nodes.
  2. Make sure your n8n instance has access to run shell commands for the Execute Command node.

3. Updating Repository Settings

  1. Open the Globals (Set node).
  2. Update repo.owner with your GitHub username.
  3. Set repo.name to your repository name where you want to save backups.
  4. Modify repo.path to the folder where backups should save (make sure to keep the trailing slash).

4. Testing the Workflow

  1. Trigger the workflow manually using the Manual Trigger.
  2. Check the execution logs for any errors or confirmation that backups were created or updated.

5. Activating for Production

  1. Activate the Schedule Trigger to run the workflow every two hours automatically.
  2. Monitor regularly to ensure backups continue without error.

You do not have to build the workflow yourself from scratch if you import it and configure as above.


Common Edge Cases and Failures

  • If the export command does not output valid JSON, the workflow will log an error in the formatting step.
  • Missing backup files in GitHub are normal at first; workflow creates new ones automatically.
  • Large backup files may require HTTP Request fallback to get raw file content instead of the API method.
  • Long credential lists may require lowering batch size in SplitInBatches node to avoid memory limits.

Customization Ideas

  • Change the folder path in GitHub by only editing repo.path in the Globals node.
  • Adjust the schedule in the Schedule Trigger node to run backups more or less often.
  • Modify batch size in the SplitInBatches node for your environment’s capacity.
  • Customize commit messages in GitHub nodes to add timestamps or descriptive notes.
  • Add error alerts after GitHub nodes to send notifications on backup failures via email or Slack.
  • If using self-host n8n, ensure your environment supports the Execute Command node and GitHub access properly.

Summary of Benefits

✓ Backup all n8n credentials automatically to GitHub.

✓ Avoid manual exports that take hours and cause mistakes.

✓ Save a secure, version-controlled backup updated only when needed.

→ Schedule backups every two hours or run manually anytime.

→ Easy to configure and test inside n8n after import.


Frequently Asked Questions

Yes, by using a personal access token with access to the private repository, this workflow can back up credentials securely.
It compares the exported credential JSON with the existing GitHub file. If the file is new or different, it updates or creates it; if unchanged, no commit happens.
If the file is too large to fetch normally from GitHub, the workflow uses an HTTP Request to get the raw file contents as a fallback.
Download the workflow file, import it inside the n8n editor, configure GitHub credentials and repo settings in the Globals node, test it once manually, then activate the scheduled trigger.

Promoted by BULDRR AI

Related Workflows

Automate Viral UGC Video Creation Using n8n + Degaus (Beginner-Friendly Guide)

Learn how to automate viral UGC video creation using n8n, AI prompts, and Degaus. This beginner-friendly guide shows how to import, configure, and run the workflow without technical complexity.
Form Trigger
Google Sheets
Gmail
+37
Free

AI SEO Blog Writer Automation Workflows in n8n

A complete beginner guide to building an AI SEO blog writer automation using n8n.
AI Agent
Google Sheets
httpRequest
+5
Free

Automate CrowdStrike Alerts with VirusTotal, Jira & Slack

This workflow automates processing of CrowdStrike detections by enriching threat data via VirusTotal, creating Jira tickets for incident tracking, and notifying teams on Slack for quick response. Save hours daily by transforming complex threat data into actionable alerts effortlessly.
scheduleTrigger
httpRequest
jira
+5
Free

Automate Telegram Invoices to Notion with AI Summaries & Reports

Save hours on financial tracking by automating invoice extraction from Telegram photos to Notion using Google Gemini AI. This workflow extracts data, records transactions, and generates detailed spending reports with charts sent on schedule via Telegram.
lmChatGoogleGemini
telegramTrigger
notion
+9
Free

Automate Email Replies with n8n and AI-Powered Summarization

Save hours managing your inbox with this n8n workflow that uses IMAP email triggers, AI summarization, and vector search to draft concise replies requiring minimal review. Automate business email processing efficiently with AI guidance and Gmail integration.
emailReadImap
vectorStoreQdrant
emailSend
+12
Free

Automate Email Campaigns Using n8n with Gmail & Google Sheets

This n8n workflow automates personalized email outreach campaigns by integrating Gmail and Google Sheets, saving hours of manual follow-up work and reducing errors in email sequences. It ensures timely follow-ups based on previous email interactions, optimizing communication efficiency.
googleSheets
gmail
code
+5
Free