Backup GIT repositories

Platform Notice: Cloud - This article applies to Atlassian products on the cloud platform.

   

Purpose

  • The purpose of this KB article is to provide instructions for performing repository backups, both on a per-repository basis as well as in bulk.
  • As per our backup policy, we perform hourly snapshot backups of your repositories and store these in AWS - our support team is able to restore your core repository content within a 7-day window of data loss.

Procedure #1 - Single repository backup

If you are seeking to perform a local backup of a singular (or a few) repositories, this can most simply be achieved by performing a mirror clone.

  • A mirror clone is a complete backup clone of your repository, it contains the full commit history, the working directory, and all the extended refs of the remote repository - it will also maintain remote branch tracking configuration.
  • To perform a mirror clone - you would simply add the --mirror flag to your regular clone command against the repository that you wish to backup:

    // Clone via SSH
    git clone --mirror git@bitbucket.org:workspaceID/repositoryslug.git
    // Clone via HTTPS
    git clone --mirror https://username@bitbucket.org/workspaceID/repositoryslug.git

Procedure #2 - Bulk repository backup

If you are seeking to perform a local backup of all of your remote repositories, this can be achieved in bulk by making use of a script - for example:

NOTE: This is a third-party script that is not formally supported by Atlassian, if you encounter any issues we will not be able to provide scripting assistance as this falls outside of our support scope. We would suggest having your team review this before executing it in production.

We have an unofficial script that can be used to handle this, along with its instructions located here: Bulk backup script

  • Before executing the bash script, you will need to create an App Password if you do not already have one - this is because the script uses our API to extract a list of the repositories belonging to your workspace
  • Once you have an App Password, you will then need to ensure that the bash script is executable by giving it the necessary permissions:

    chmod 777 account_repo_backup.sh
  • Once complete, you can then execute the script - including the necessary authentication and workspace location parameters as follows:

    ./account_repo_backup.sh <Username> <AppPassword> <WorkspaceID>


If you are encountering issues following this documentation, or have any other related questions - please raise a support ticket or raise a community support ticket for further assistance with the backup procedure.

DescriptionBackup GIT repositories
ProductBitbucket Cloud
Last modified on Sep 18, 2023

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.