Backup Stash without repositories

A backup of our production Stash using the official backup client currently takes about two hours(!), which is much, much more downtime as allowed for the system. As far as I see most of the time is taken for tar-ing all the git repositories, which doesn't make any sense to me at all. (The repositories are already cloned for each developer and also pushed to a second git server, as an official backup.)

Is there a way to backup everything except the actual repositories?

Is there some other way to have some kind of backup of the stash instance without a noteworthy downtime?

1 answer

1 vote
Brent Plump Atlassian Team Nov 24, 2013

Hi Michael,

There is no way to tell the backup client to backup only the database or only repositories. The backup client is intended to backup the entire Stash server and it's crucial that the database and repositories are in-sync with each other.

We investigated a number of backup methods when writing the backup client, including using the Git client to perform a clone. The Git repositories that Stash keeps in the {{data}} directory are configured very specifically for Stash's use. Unfortunately, using Git to backup Stash's repos will:

  • Resolve symbolic references in the pull request references
  • Skip pull request ref logs, which can break diffs on pull requests
  • Pull in objects from fork parents, negating significant disk space savings for forks
  • Lose git config and other metadata we store in the git directory ('dark' pull request refs)

As a result of the above issues, we decided tarring the files in Java was the fastest, cross-platform way to backup. We anticipated that larger organizations may have faster means available (rsync or file-system snapshots, for example).

If you decide to go your own route, there are two main points to keep in mind:

  • There cannot be any git write operations in-progress or you risk copying the repos in an invalid and unrecoverable state
  • Your database and filesystem backups must be in-sync

To ensure the above two points are met, we'd suggest stopping the Stash server during a backup or blocking access to the HTTP and SSH ports.

Lastly, we're aware people aren't happy about the downtime required for a backup. We're looking into other ways to handle backups without downtime (potentially with the use of mirrors or clusters). However, those solutions will take a lot of development and probably won't be released until later this year.

I hope that helps,

-- Brent

Gitolite has mirror.master and mirror.slaves, which is so awesome! Hope Stash will have similar feature

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Thursday in Bitbucket Pipelines

Building a Bitbucket Pipe as a casual coder :  #!/bin/bash source "$(dirname "$0")/" enable_debug extra_args="" if [[ "${DEBUG}" == "true" ]]; then extra_args="--verbose" fi # mandatory variables R...

228 views 0 12
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you