I'm using Bitbucket cloud. How do I backup all my team's repositories? or Does Atlassian back it up?
2 Answers
Atlassian backs up their data for disaster recovery purposes, but note that this isn't meant to be your backup:
Our backups are for disaster recovery purposes only. We are not able to use our backups to restore repositories that have been deleted by an end-user.
Thankfully, every copy of a Git or Mercurial repository contains the full history of your code:
One of the great features of distributed version control systems (DVCS) such as Git and Mercurial is that they're distributed. Backups are still very important, but consider that every person on your team that has forked your repository has a complete copy with a full history.
If you use Bitbucket wikis those can be backed up similarly since they are repositories too.
If you use Bitbucket issues you can use the import / export feature to back them up.
#!/bin/bash #===================================================# ## Author: Ankit Vishwakrma #---------------------------------------------------- ## Modified Date : 29/12/2022 ## Usage: This script will take clone for all the repos from bitbucket ## declared inside repos.conf file. Please refer README.md file for more ## details. #===================================================# BASE_DIR="/location/where/this/script/is/kept/" BITBUCKET_USERNAME=<<username>> BITBUCKET_PASSWORD=<<password>> # Read the array of repositories from the repos.conf file, filtering out lines starting with # # We can use the array of repositories also readarray -t repos < <(grep -v '^#' $BASE_DIR/repos.conf) # Generate a timestamp in the format YYYY-MM-DD timestamp=$(date +%Y%m%d%H%M%S) # Create the backup directory with the timestamp in the name backup_dir="$BASE_DIR/repos/$timestamp" if [ ! -d "$backup_dir" ]; then mkdir -p "$backup_dir" fi # Change to the backup directory cd "$backup_dir" # Iterate over the list of repositories for repo in "${repos[@]}"; do # Clone the repository to the backup directory git clone "[email protected]/<<projectname>>/$repo.git" "$backup_dir/$repo" if [ $? -eq 0 ]; then # Clone was successful echo "Git clone successful! for repo: $repo" else # Clone failed, try again echo "Git clone failed for repo : $repo. Trying again..." fi done