Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Automated backup of git repositories

Roy Nard July 13, 2023

I am looking for standardized way,  or close to standardized way (maybe using bitbucket's API) to make periodic backups of our git repos.

 

What are sane alternatives for this?

Assume that we already have a machine and storage in a safe location that can poll for changes and clone repos.

2 answers

1 accepted

2 votes
Answer accepted
Aron Gombas _Midori_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 13, 2023

We do this (and I know a few others do the same). We developed a dead-simple script that "git pulls" all our repositories from Bitbucket Cloud and then "git pushes" them to GitHub. And we put this to a regular Linux CRON job and run in every 5 minutes.

Basically, we have a perfect copy of all repos with the max latency of 5 minutes. It works flawlessly. Bonus: if Bitbucket Cloud were down, we could continue collaboraing on GitHub.

Roy Nard July 14, 2023

Great to hear - this is a generic solution not using the Bitbucket API.
If you think that this solution is optimal and have maybe checked the API a bit for "better flows" then that would save me some time on research before implementation.

Aron Gombas _Midori_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 14, 2023

To be honest, I haven't checked if there are better, Bitbucket Cloud specific solution to the problem. 

Why? I was looking for a solution that I can use by backup our Bitbucket Cloud, Bitbucket Data Center, other_potential_Git_hosting_service_here repositories with a single script. Also I didn't want to touch the script if the API introduces breaking changes. In fact, low cost, simplicity and robustness are key advantages of my approach. (I ever have to throw it out, we may waste a few hours max.)

Roy Nard July 14, 2023

Makes sense.
Either way, thanks for the quick answer.

My approach will probably be generic although I will use some programming language with lib to Prometheus so I can monitor the backup process and available server storage.

Many thanks,  

Like Aron Gombas _Midori_ likes this
Roy Nard July 14, 2023

256 accepted answers, be aware of overflow ;)

Like Aron Gombas _Midori_ likes this
Aron Gombas _Midori_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 14, 2023

Because it was successfully increased to 256, it means that it is at least two bytes, so I'm pretty safe until 65K accepted answers... :-D

Roy Nard July 14, 2023

True, but maybe the last increment was JavaScript.

 

never underestimate the power of legacy terror

JCamacho
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 10, 2023

Question, in the script you wrote, do you have to hard-code your repo names? We have over 100 repos, and I don't think a good backup strategy would be to remember to hard-code in every new repo name.

Aron Gombas _Midori_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 10, 2023

Well, both Bitbucket Cloud and GitHub offers REST APIs to get all repositories, so you don't have to enumerate them if you want to backup all.

If, for example, you can match the repo on the two sites based on the repository slug, then it is easy to implement a "backup all repos" logic.

Abdo Haidar
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 30, 2024

hello Aron,

I was wondering if i want to have this procedure of backing up all my repo from bitbucket and push them to Github, how can i obtain this procedure.

 

Thanks.

1 vote
Daria Kulikova_GitProtect_io
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 17, 2023

Hi @Roy Nard ,

You can take a look at GitProtect.io, an automated backup & DR software for Bitbucket. With the solution, you can set a scheduler for your backups to be performed automatically. Moreover, the solution permits you to bring your own storage.


You can find out more about the GitProtect on the Atlassian Marketplace: https://marketplace.atlassian.com/apps/1225728/gitprotect-io-backup-for-bitbucket?hosting=cloud&tab=overview

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events