Backup n8n Credentials to GitHub

This workflow primarily implements automatic backup of all credentials to a GitHub repository, with files named according to the workflow ID and saved in JSON format. It supports scheduled execution and manual triggering, and can automatically compare the differences in backup files to ensure updates only occur when changes are detected, thereby reducing storage space and redundant commits. By processing each credential data in a loop, it optimizes memory usage. This workflow provides users with secure and reliable credential management and version control, enhancing backup efficiency and reducing manual operations.

Workflow Diagram
Backup n8n Credentials to GitHub Workflow diagram

Workflow Name

Backup n8n Credentials to GitHub

Key Features and Highlights

This workflow automates the backup of all n8n instance credentials to a GitHub repository, saving each file in JSON format named by the workflow ID. It supports both scheduled execution and manual triggering. The workflow automatically compares differences between backup files to ensure updates occur only when changes are detected, effectively saving storage space and reducing redundant commits. By processing each credential entry through a sub-workflow loop, it optimizes memory usage.

Core Problems Addressed

  • Automates the backup of n8n credentials to prevent credential loss risks
  • Avoids redundant backups by comparing file differences and backing up only changed data
  • Centralizes credential backup files for easier version control and recovery
  • Minimizes manual operations, enhancing backup efficiency and security

Use Cases

  • n8n users who want to regularly back up credentials to GitHub for secure credential management
  • Teams collaborating on development, requiring centralized management and tracking of credential change history
  • Organizations needing automated credential backups to meet compliance and audit requirements
  • Backup processes that need to save storage space and avoid unnecessary repeated commits

Main Workflow Steps

  1. Trigger the workflow execution either on a schedule or manually
  2. Execute commands to export all decrypted n8n credentials
  3. Format and split the credential data into multiple entries
  4. Loop through each credential entry, reading the corresponding backup file from GitHub
  5. Check whether the file exists and if it exceeds size limits
  6. Compare the current credential data with the backup file content for differences
  7. Based on the difference status, decide to create a new file, edit an existing file, or skip the operation
  8. Commit changes to GitHub to complete the backup

Involved Systems or Services

  • n8n: Automation platform used for exporting credentials and managing workflows
  • GitHub: Backup storage repository managing credential JSON files
  • Built-in n8n nodes: Including Execute Command, HTTP Request, Code, Switch, Merge, Schedule Trigger, Execute Workflow, etc., to implement workflow control and logic decisions

Target Audience and Value

  • n8n platform administrators and operations personnel ensuring credential security and recoverability
  • Automation developers aiming to enhance the automation level of credential management
  • Teams working collaboratively, facilitating credential version control and change tracking
  • Enterprise users requiring compliant management of credential backup processes

This workflow significantly reduces the risk of credential loss and improves backup maintenance efficiency through automated and intelligent backup management, making it an ideal solution for n8n users to maintain system security and stability.