Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Bitbucket DIY backup with mysql

Michael Wolfe
Community Champion
June 14, 2018

I wanted to implement the DIY backup method for my bitbucket server for additional redundancy.  Though I feel like the black sheep as I chose to go with mysql as my database format where it seems everyone else is using Postgres.  Has anyone else successfully got this setup on their server?

I have most of the variables set up, but I don't see anything specific for mysql database users, or backup location.  Could I just follow the example on Atlassian's page and omit the Postgres stuff specifically?

https://confluence.atlassian.com/bitbucketserver/using-bitbucket-server-diy-backup-776640056.html

1 answer

1 accepted

0 votes
Answer accepted
Michael Wolfe
Community Champion
June 14, 2018

I've made a little headway, but I'm getting this error when I run the script:

bitbucket.diy-backup.sh:0 -> main][jira-test] INFO: Preparing for backup
[database-mysql.sh:48 -> prepare_backup_db][jira-test] INFO: Prepared backup of DB bitbucketdb in /mnt/bitbackup/bitbucket-backup/bitbucket-db/
[common.sh:52 -> lock_bitbucket][jira-test] ERROR: Unable to lock Bitbucket for maintenance. POST to 'http://bitbucket-test:7990/mvc/maintenance/lock' returned ''

Stack trace:
[./common.sh:52 -> lock_bitbucket]
[./bitbucket.diy-backup.sh:0 -> main]

I had to modify the curl option to include --noproxy for my bitbucket server as I'm proxying the port.  I have also tested that curl works with the options below.  Still not sure what I may need to change, but I'll keep digging and update this thread.

#!/bin/bash

CURL_OPTIONS="-L -s -f --noproxy bitbucket-test"
INSTANCE_NAME=bitbucket

BITBUCKET_URL=http://bitbucket-test:7990
BITBUCKET_HOME=/var/atlassian/bitbucket-home/
BITBUCKET_UID=atlbitbucket
BITBUCKET_GID=atlbitbucket

BACKUP_HOME_TYPE=rsync
BACKUP_DATABASE_TYPE=mysql
BACKUP_ARCHIVE_TYPE=tar

BITBUCKET_BACKUP_USER=root
BITBUCKET_BACKUP_PASS=password
BITBUCKET_BACKUP_EXCLUDE_REPOS=()

BITBUCKET_DB=bitbucketdb
MYSQL_HOST=localhost
MYSQL_USERNAME=bitbucketdbuser
MYSQL_PASSWORD=password
MYSQL_PORT=3306

# Make use of PostgreSQL 9.3+ options if available
#psql_version="$(psql --version | awk '{print $3}')"
#psql_majorminor="$(printf "%d%03d" $(echo "${psql_version}" | tr "." "\n" | head -n 2))"
#if [[ ${psql_majorminor} -ge 9003 ]]; then
# PG_PARALLEL="-j 5"
# PG_SNAPSHOT_OPT="--no-synchronized-snapshots"
#fi

BITBUCKET_BACKUP_ROOT=/mnt/bitbackup/bitbucket-backup
BITBUCKET_BACKUP_DB=${BITBUCKET_BACKUP_ROOT}/bitbucket-db/
BITBUCKET_BACKUP_HOME=${BITBUCKET_BACKUP_ROOT}/bitbucket-home/

BITBUCKET_BACKUP_ARCHIVE_ROOT=${BITBUCKET_BACKUP_ROOT}/bitbucket-backup-archives

# Used by the scripts for verbose logging. If not true only errors will be shown.
BITBUCKET_VERBOSE_BACKUP=TRUE
Michael Wolfe
Community Champion
June 14, 2018

It would appear that I needed to use a user account that has administrative access to bitbucket.  Here is the variable config that I am using currently.

#!/bin/bash

CURL_OPTIONS="-L -s -f "
INSTANCE_NAME=bitbucket

BITBUCKET_URL=http://bitbucket-test.domain.com
BITBUCKET_HOME=/var/atlassian/bitbucket-home/
BITBUCKET_UID=atlbitbucket
BITBUCKET_GID=atlbitbucket

BACKUP_HOME_TYPE=rsync
BACKUP_DATABASE_TYPE=mysql
BACKUP_ARCHIVE_TYPE=tar

BITBUCKET_BACKUP_USER=bitbucketUser
BITBUCKET_BACKUP_PASS=passW0rd
BITBUCKET_BACKUP_EXCLUDE_REPOS=()

BITBUCKET_DB=bitbucketdb
MYSQL_HOST=localhost
MYSQL_USERNAME=bitbucketdbuser
MYSQL_PASSWORD=pasw0rd
MYSQL_PORT=3306

# Make use of PostgreSQL 9.3+ options if available
#psql_version="$(psql --version | awk '{print $3}')"
#psql_majorminor="$(printf "%d%03d" $(echo "${psql_version}" | tr "." "\n" | head -n 2))"
#if [[ ${psql_majorminor} -ge 9003 ]]; then
# PG_PARALLEL="-j 5"
# PG_SNAPSHOT_OPT="--no-synchronized-snapshots"
#fi

BITBUCKET_BACKUP_ROOT=/mnt/bitbackup/bitbucket-backup
BITBUCKET_BACKUP_DB=${BITBUCKET_BACKUP_ROOT}/bitbucket-db/
BITBUCKET_BACKUP_HOME=${BITBUCKET_BACKUP_ROOT}/bitbucket-home/

BITBUCKET_BACKUP_ARCHIVE_ROOT=${BITBUCKET_BACKUP_ROOT}/bitbucket-backup-archives

# Used by the scripts for verbose logging. If not true only errors will be shown.
BITBUCKET_VERBOSE_BACKUP=TRUE

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events