Automated Backup and Configuration Change Detection to GitHub - n8n Workflow

Secure your n8n instance with this automated n8n workflow. It uses scheduled triggers and hash-based change detection to back up all n8n templates, configuration, and credentials to GitHub, ensuring only real changes are committed.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • n8n system administrators and DevOps teams managing self-hosted instances.

  • Users who need version control for their n8n workflow templates and sensitive credentials.

  • Developers aiming to maintain a clean GitHub repository by only committing configuration changes.

Overview

Maintaining a robust backup strategy is critical for any production n8n environment. This advanced n8n workflow template addresses the inefficiency of constantly committing full backups by integrating hash-based change detection. The automation ensures that exports of all n8n templates, workflows, and associated credentials are only pushed to a designated GitHub repository if a substantive modification has occurred (e.g., a new n8n node was added, or a credential was updated).

The implementation uses the Execute Command n8n node to perform essential n8n export commands and a secondary n8n workflow (referenced via the Execute Workflow n8n node) to calculate SHA256 hashes for efficient comparison. This smart approach minimizes redundant commits and provides a clean, reliable version history for your entire n8n deployment, enhancing overall system reliability and compliance.

How it Works

This automation starts with a time-based n8n trigger and splits into two parallel branches: one for backing up workflows and one for credentials.


  1. Trigger and Path Definition: The Schedule Trigger serves as the primary n8n trigger, initiating the process hourly. Initial Set n8n node operations define the local file paths (/data/shared/WorkFlowBackup.json and /data/shared/CredentialBackup.json) where temporary export files will reside.

  2. Hash Comparison: Before performing the new export, the n8n workflow uses the Execute Workflow n8n node ('Get Old Hash') to calculate the SHA256 hash of the existing backup file (if any).

  3. Export and New Hash: The Execute Command n8n node runs the official n8n export:workflow --all or n8n export:credentials --all commands. Immediately afterward, the n8n workflow runs the Execute Workflow n8n node again ('Get New Hash') on the freshly created file.

  4. Conditional Commit: An If n8n node ('If Workflow Updated'/'If Credential Updated') compares the old and new hashes. If the hashes are unequal, indicating a change in the n8n workflow or n8n node configuration, the flow proceeds down the true path.

  5. Data Extraction and GitHub Upload: The relevant JSON data is read and extracted from the temporary file. Finally, the GitHub n8n node commits the content to the target repository with a clear, timestamped commit message, guaranteeing a consistent backup of all n8n templates and core system data.

Installation Guide

To deploy this n8n workflow, follow these steps:


  1. Import the JSON: Copy the provided JSON data and paste it into your n8n instance using the 'Import from JSON' option.

  2. Set up the Hash Helper: This n8n workflow relies on a second, separate n8n workflow (referenced by ID U7Jh9njKLEjGLVIl) to handle the SHA256 hashing. Ensure this helper workflow exists or modify the Execute Workflow n8n node parameters to point to your hashing utility.

  3. Configure File Paths: The Set Workflow Path and Set Credential Path n8n nodes default to /data/shared/. If your n8n environment uses different volume mounts or permissions, adjust these paths accordingly.

  4. GitHub Credentials: Configure the GitHub n8n node credentials. You will need a Personal Access Token (PAT) with write access to the target repository.

  5. Repository Details: In the 'GitHub Workflow Backup' and 'GitHub Credential Backup' n8n nodes, update the Owner and Repository parameters to match your desired GitHub backup location.

  6. Activate the n8n Trigger: Ensure the Schedule Trigger n8n trigger is active to start the hourly backup routine.

Node Details

Schedule Trigger: The starting n8n trigger. Configured to run the n8n workflow automatically at defined intervals (hourly in this configuration).
Set Workflow Path / Set Credential Path (Set n8n node): Defines the absolute path on the n8n host where the exported JSON files will be temporarily saved (/data/shared/...).
Execute Workflow (Get Old/New Hash): A crucial n8n node. This executes a separate n8n workflow (U7Jh9njKLEjGLVIl) to calculate the SHA256 hash of the specified file path, enabling the core change detection logic for the entire n8n workflow structure.
Execute Command: Runs command-line interfaces within the n8n host. Used here for n8n export:workflow --all and n8n export:credentials --all to generate current configuration snapshots.
If (n8n node): Provides core logic flow control. It compares the leftValue (New Hash) and rightValue (Old Hash). If the values are not equal (notEquals), indicating a change, the subsequent backup steps execute.
Read Write File / Extract From File: These n8n nodes handle reading the newly created JSON backup files from the disk and extracting the content as a string, preparing it for upload.


  • GitHub: The final action n8n node. It creates a new file (resource set to file) in the specified repository (nickmehr-hamed/n8n) using the extracted data, ensuring your n8n workflow templates are safely backed up.

Related n8n Workflows

Free

Nodes: 10 Nodes
Updated: December 26 2025
View all
Created by
Hamed Nickmehr
Hamed Nickmehr

Featured*