n8n

How to Sync n8n to Bitbucket Version Control?

Back up your n8n workflows to Bitbucket every night. The system checks each workflow and commits only files that are new or changed. Teams gain a clear history and an easy way to roll back.

A 2 AM schedule starts the run. The n8n API pulls the full list of workflows, then a batch loop handles them one by one. For each item, a Bitbucket check looks for an existing file. A condition decides if the file has changed. If yes, a commit is created with a clean file name and a time stamp in the message. After each commit, a small code step reads headers to set a safe wait time, and a wait step pauses to avoid rate limits before the next item runs.

Setup is simple. Add credentials for your n8n instance and for Bitbucket, and set your workspace and repository once in the Set node. Expect near zero manual effort, fewer mistakes, and a solid audit trail. This is ideal for teams that run many n8n jobs and want dependable version control and nightly backups.

What are the key features?

  • Daily schedule runs at 2 AM to capture overnight changes
  • Central workspace and repository settings managed in one Set node
  • Pulls all workflows from your n8n instance using the n8n API
  • Processes workflows in batches to control load and order
  • Checks Bitbucket for an existing file before deciding to commit
  • Compares content and only commits when a workflow is new or changed
  • Creates commits with a sanitized file name and a timestamped message
  • Reads response headers to calculate a safe pause and avoid rate limits

What are the benefits?

  • Reduce manual export and commit from 60 minutes to 5 minutes per day
  • Automate 100 percent of routine workflow backups
  • Improve data accuracy by removing copy and paste errors
  • Handle 10 times more workflows without hitting rate limits
  • Connect n8n and Bitbucket so version history stays in one place

How do you set it up?

  1. Import the template into n8n: Create a new workflow in n8n > Click the three dots menu > Select 'Import from File' > Choose the downloaded JSON file.
  2. You'll need accounts with n8n and Bitbucket. See the Tools Required section above for links to create accounts with these services.
  3. Open the Set Bitbucket Workspace & Repository node and enter your WorkspaceSlug and RepositorySlug exactly as they appear in Bitbucket.
  4. Connect your n8n API: double click the Get All Workflows node, open the credential dropdown, click Create new credential, then follow the on screen instructions to connect your n8n instance.
  5. Create Bitbucket credentials: in Bitbucket, create an App password with Repository read and write. In n8n, open each Bitbucket HTTP Request node, choose HTTP Basic Auth, set your Bitbucket username and the App password, then save.
  6. Confirm the branch: the GET step uses the path src/main. Make sure your default branch is named main, or update the URL in both Bitbucket HTTP Request nodes to match your default branch.
  7. Review commit details: in the Upload step, the message field already includes the workflow name and timestamp. Keep it as is or adjust the text to match your commit style.
  8. Run a test: click Execute on the workflow during work hours to verify connections. Watch the run to see at least one commit post to Bitbucket.
  9. Check results in Bitbucket: open the repository, confirm new files appear with clean names, and check the commit history for the timestamped messages.
  10. Validate skip logic: re run the workflow and confirm that unchanged files are skipped by the New or Changed decision step.
  11. Enable the schedule: activate the workflow in n8n so it runs nightly at 2 AM. Adjust the schedule if your maintenance window is different.
  12. Troubleshoot common issues: a 401 error means your Bitbucket username or App password is wrong. A 404 on the GET step is normal on first run when the file is not yet in the repo. If you hit rate limits, the Wait step will extend the pause automatically.

Tools Required

$24 / mo or $20 / mo billed annually to use n8n in the cloud. However, the local or self-hosted n8n Community Edition is free.

Bitbucket

Sign up

Free: $0 for up to 5 users per workspace (Bitbucket Cloud Free plan)

n8n API

Sign up

Community Edition (self-hosted): $0 (public REST API available). Cloud Starter: $20 / mo billed annually ($24 monthly); API unavailable during free trial.

Similar Templates

Join Futurise to access 1,200+ automation templates

Get instant access to ready-made automation workflows for n8n, Make.com, AI agents, and more. Download, customise, and deploy in minutes.