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
Backup n8n credentials to GitHub

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

Learn how to Build this Workflow with AI:

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.


Backup n8n credentials to GitHub

Visit through Desktop to Interact with the Workflow.

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 Twist Channel Creation and Messaging with n8n

This workflow automates creating and updating a channel in Twist and sending a personalized message to specific users. It eliminates manual setup errors and saves time managing Twist communications.

Automate Ideogram Image Generation with Google Sheets & Gmail

This workflow automates graphic design image generation via Ideogram AI, storing image data in Google Sheets and Google Drive, with email alerts via Gmail. It saves designers hours by automating image creation, remixing, review, and record-keeping.

Automate IT Support with Slack and OpenAI in n8n

Streamline IT support by automating Slack message handling using n8n and OpenAI. This workflow handles Slack DMs, filters bots, queries a Confluence knowledge base, and delivers AI-generated responses, improving support efficiency and response time.

Automate Crypto Analysis with CoinMarketCap & n8n AI Agent

Discover how this unique n8n workflow leverages CoinMarketCap’s multi-agent AI to deliver precise, real-time cryptocurrency insights directly via Telegram. Manage crypto data analysis efficiently with automated multi-source API integration.

Automate Gumroad to Beehiiv Subscriber Sync with n8n

Learn how to automatically add new Gumroad sales customers as Beehiiv newsletter subscribers using n8n automation. This workflow saves time by syncing sales data to Google Sheets CRM and notifying your Telegram channel instantly.

Generate On-Brand Blog Articles Using n8n and OpenAI

This workflow automates the creation of on-brand blog articles by analyzing existing company content using n8n and OpenAI. It extracts article structures and brand voice to produce consistent draft articles, saving significant content creation time.
1:1 Free Strategy Session
Your competitors are already automating. Are you still paying for it manually?

Do you want to adopt AI Automation?

Every hour your team does repetitive work, you're burning real money.
While you wait, faster businesses are cutting costs and moving quicker.
AI and automations aren't the future anymore — they're the present.

Book a live 1-on-1 session where we show you exactly which of your daily tasks can be automated — and what it’s costing you not to.