Backup n8n Workflows to Bitbucket

Backup n8n workflows to Bitbucket automatically every day at 2 AM, ensuring your workflows are securely stored and up-to-date. This workflow efficiently handles multiple workflows, checks for changes, and avoids rate limits, providing peace of mind and reliability in your automation processes.

7/8/2025
9 nodes
Complex
schedulecomplexschedule triggern8nsplitinbatcheswaitautomationcronapiintegrationlogicconditional
Categories:
Schedule TriggeredComplex Workflow
Integrations:
Schedule TriggerN8nSplitInBatchesWait

Target Audience

This workflow is ideal for:
- Developers and DevOps Engineers: Those who need to automate the backup of their n8n workflows to Bitbucket.
- Project Managers: Individuals managing multiple workflows who want to ensure version control and backup.
- System Administrators: Professionals responsible for maintaining workflow integrity and preventing data loss.
- Teams using n8n for Automation: Groups that rely on n8n for various automated processes and want to secure their configurations.

Problem Solved

This workflow addresses the challenge of ensuring consistent backups of n8n workflows to Bitbucket, thereby mitigating the risk of data loss. It automates the process of checking for existing workflows, uploading new or modified workflows, and managing API rate limits effectively. By scheduling this task to run daily at 2 AM, it guarantees that the workflows are regularly updated in the repository without manual intervention.

Workflow Steps

  • Schedule Trigger: The workflow is initiated daily at 2 AM using a schedule trigger.
    2. Set Bitbucket Workspace & Repository: It defines the Bitbucket workspace and repository where workflows will be backed up.
    3. Get All Workflows: The workflow retrieves all existing workflows from n8n.
    4. Loop Workflows: Each workflow is processed in batches to handle multiple workflows efficiently.
    5. Get Existing Workflow from Bitbucket: For each workflow, it checks if a backup already exists in Bitbucket.
    6. New or Changed?: It determines if the workflow is new or has been modified by comparing the current version with the one in Bitbucket.
    7. Upload Workflow to Bitbucket: If the workflow is new or changed, it uploads the workflow to Bitbucket, including a commit message with a timestamp.
    8. Calculate Wait Time: To avoid hitting API rate limits, it calculates a wait time based on the rate limit headers received from Bitbucket.
    9. Wait to Avoid Rate Limiting: The workflow pauses for the calculated wait time before processing the next workflow.
  • Customization Guide

    To customize this workflow:
    - Modify Schedule: Change the trigger time in the Run Daily at 2 AM node to suit your needs (e.g., run at a different hour).
    - Adjust Bitbucket Credentials: Update the Bitbucket credentials in the Upload Workflow to Bitbucket and Get Existing Workflow from Bitbucket nodes to match your repository settings.
    - Change Workspace and Repository: Update the values in the Set Bitbucket Workspace & Repository node to point to your specific Bitbucket workspace and repository.
    - Alter Workflow Logic: You can modify the condition checks in the New or Changed? node to fine-tune the criteria for uploading workflows.
    - Handle Additional Workflows: If you have more workflows to back up, adjust the Loop Workflows node to increase the batch size or add additional processing logic.