Backup n8n Workflows to Bitbucket

This workflow is designed to automatically back up all workflows to a Bitbucket code repository, ensuring data security and version management. It executes on a scheduled daily basis, automatically detecting any additions or changes to the workflows and only synchronizing the parts that need to be updated, thereby saving resources. Additionally, it dynamically calculates request intervals to avoid API call frequency limits, ensuring an efficient and stable backup process. It is suitable for teams and individuals who need to regularly back up and manage automated processes.

Workflow Diagram
Backup n8n Workflows to Bitbucket Workflow diagram

Workflow Name

Backup n8n Workflows to Bitbucket

Key Features and Highlights

This workflow automates the backup and synchronization of all workflows on the n8n platform to a Bitbucket code repository. It supports scheduled daily execution, automatically detects new or modified workflows to avoid redundant uploads, and dynamically calculates wait times to circumvent Bitbucket API rate limits, ensuring a stable and efficient backup process.

Core Problems Addressed

  • Automates backup of n8n workflows to prevent data loss
  • Monitors workflow changes in real-time, syncing only new or updated workflows to save resources
  • Handles Bitbucket API rate limiting to prevent failures caused by excessive requests
  • Executes on a schedule without manual intervention, ensuring continuous and reliable backups

Use Cases

  • n8n workflow development teams seeking version control for all workflows
  • Automatic backup of critical automation configurations to ensure business continuity
  • Storing workflow configurations as code for easier auditing and rollback
  • Enterprises or individual users who want to regularly sync workflows to a cloud-based code repository

Main Process Steps

  1. Scheduled Trigger (Run Daily at 2 AM): Initiates the backup process every day at 2 AM
  2. Configure Bitbucket Repository Information (Set Bitbucket Workspace & Repository): Sets the target workspace and repository name
  3. Retrieve All n8n Workflows (Get All Workflows): Fetches the complete list of workflows from the n8n system
  4. Loop Through Each Workflow (Loop Workflows)
  5. Check Existing Workflow File in Bitbucket (Get Existing Workflow from Bitbucket): Verifies if the workflow file already exists in the repository
  6. Determine if New or Updated (New or Changed?): Compares local workflow content with the repository version
  7. Upload Updated Workflows (Upload Workflow to Bitbucket): Commits new or modified workflow JSON files to Bitbucket
  8. Calculate Wait Time (Calculate Wait Time): Dynamically adjusts request intervals based on Bitbucket API rate limit feedback
  9. Delay to Avoid Rate Limiting (Wait to Avoid Rate Limiting)
  10. Continue Processing Next Workflow Until All Are Synced

Involved Systems or Services

  • n8n: Automation workflow platform serving as the source of workflow data
  • Bitbucket: Code hosting service used for storing workflow versions and backups
  • HTTP Request Node: Interacts with Bitbucket API to retrieve and submit files
  • Scheduled Trigger: Enables daily automatic execution
  • Code Node: Dynamically calculates wait times to optimize request frequency

Target Users and Value

  • n8n platform administrators and developers
  • Teams requiring secure and version-controlled automation workflows
  • Individuals or organizations aiming for automated backup and version management
  • Teams managing workflows via code repositories for easier change tracking and collaboration

This workflow not only enhances the security and standardization of workflow management but also effectively mitigates the risk of API call failures due to rate limiting, empowering users to effortlessly maintain continuous backup and version control of their automation workflows.