Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,367,735
Community Members
 
Community Events
168
Community Groups

Bitbucket Backup

Edited

Hello,

I am using a windows environment and self hosted "Server" version of bitbucket

I've read several docs on how to do a bitbucket backup but the "Client" looks dated and im not sure how to proceed with that.

Why does bitbucket not have a native backup option like confluence has ?

Documentation is important but you know what is even more important ?

CODE...

Suggestions, help, advice, tutorials...

Essentially what Im looking for is to have a nightly backup made like I have with confluence and store it on another server which is a normal procedure when it comes to data.

Again I am on a pure windows environment with a MSSQL as the database and self hosted "Server" version of bitbucket

 

Thanks

5 answers

1 accepted

1 vote
Answer accepted

Hi Siavash,

for backup the bitbucket you need to backup two things 

1. data directory 

2. database

 write  batch file to copy your bitbucket data directory to your backup machine every day ,

for database you can write a procedure to backup db every day and copy to backup machine 

When you backup any GIT environment (e.g.: Bitbucket) you need to take into account a few things:

1. Decide what you want to backup:

  • code repository - could be run as simple as git clone
  • metadata (depending on the provider): issues, comments, downloads, deployment keys, pull requests, labels, milestones, pipelines, projects - it requires much more work.

2. Decide on a backup and recovery approach. Depending on the deployment model (SaaS, DC, on-premise) not all of them are available 

  • Use the built-in mechanism.
  • Write own scripts that use GIT and API.
  • Write scripts to backup DB and directory
  • Back up the whole server. 

3. Run tests for both backup and recovery scenarios. 

  • You could have multiple backups but none of them could be recovered

4. Monitor and maintain your solution

  • You need to be sure that your backups are working
  • Get notifications when something is wrong
  • Plan recovery drills to test the whole setup
  • Update solution when it's not working

Other important areas to decide:

  • Type of backups full, incremental, differential
  • Where to store backups
  • How data retention policy should look
  • How to secure data and who should have access to backups
  • Create recovery plans/procedures etc.
  • How your backup solution will impact performance and API thresholds. 

In the beginning, it looks like writing a few scripts but it could also end in a pretty large project that will require additional resources to maintain.  You could do everything on your own or use a dedicated Bitbucket backup platform.

Hello,

Am using Bitbucket Server self host but not using any database,then HOW should i backup and restore????

I suggest taking a look at SCM Backup tool: https://github.com/christianspecht/scm-backup

We've been using this tool through a Jenkins job to take daily backups of our repositories. It's very convenient and works cross-platform. 

Like # people like this

Hello @Haas, regarding SCM, can you confirm if in fact it doesn’t back up the source files?
In a possible restoration of the data, he will seek the sources from which place?

thank's.

I'm not sure what you mean by source files. It backs up everything in a given git repository as a bare repository. The restoration is a manual task which is not a function of SCM. You just need to copy the back up to the place you want and then just "git clone bare-repo working-repo". You can see the details in its documentation.

Like Vinicius B. Dezan likes this

@Haas 

I understood, in this case, what I was referring to would be the project's source codes, as these are not saved in the backup file, as described in this part of the documentation:

"Your complete history and your source code are in there - you just don’t see the actual files!

The repository is backed up without a working directory, because it’s not necessary. "

In reality I did not understand very well what it says there, in this case, the source codes are also backed up or when I restore the backup will I have to get the source codes from my local workspace or from my bitbucket repository?

thank you again.

Like Haas likes this

@Vinicius B. Dezan 

I see your confusion. That's the "bare repository" concept. It seems strange at first glance, indeed. However, it's very simple and it actually forms the backbone of the whole git system.

A bare repository is basically what we call a remote repository in practice, in our case Bitbucket. It's used for centralizing the code versioning for the developers who share it, as you know. Because no one ever makes edits directly to files in the shared bare repo, a working tree is not needed. That's why I mentioned in my previous post "working-repo". If you think about it, it makes sense: it's "bare" because it does not have a working tree. ;)

What SCM does is simple: it creates a new bare repo for you and it becomes your backup file for that repository. Therefore, to restore your working repository to your local environment, you just need to clone from the backup file, just like cloning from a remote repo. In the end, after restoration, you'll see the source code files in your local. Depending on the type of restoration, there might be some additional things to do, such as changing the remote repo URL or (re)tracking all the remote branches, etc.

Like Vinicius B. Dezan likes this

@Haas 

Now I understand, so in this case, even though there are several developers working on the project, I can do the restoration from a previous day for example using the backup made by SCM (daily backup with the same) and with that, I will have all the source code with the changes that day, without relying on bitbucket or any local directory, correct?

Thank you very much again for returning.

@Vinicius B. Dezan 

You're welcome and yes, what you said is correct.

Like Vinicius B. Dezan likes this

Hello,

Before performing a backup should I stop the bitbucket service ?

Reminder this is a windows environment..

 

Thanks

No need , but you should scheduled backup at night time when server is not busy  

OK great.

I got some scripts to write...

 

Thank You

0 votes

HI @CenturyX476

Why does bitbucket not have a native backup option like confluence has ?

As you will know the bitbucket has the code and for native backup, it will take a lot of time (depends on data) as well as consume memory.

As @ajeet_singh said, you can sync your <Bitbucket_Home> dir to your backup server every interval time (depends on you how to want to sync at every an hour/day) and you can write a bash script using which you can take the database backup.

For running automatically the Bash script you need to add the corn job accordingly.

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events