Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Bitbucket DIY backup with mysql

Altran March 5, 2019

Dear all,

 

I've just finished installing and configuring 2 BitBucket Server instances on the very same host.

 

I have both working perfectly integrated with Jira and Confluence. Each Bitbucket instance has its own Jira and its own Confluence instances.

Behind all instances I have MySQL with 6 databases (2 Jira's, 2 Confluence's and 2 Bitbucket's).

 

I have configured local backups for both Jira's and both Confluence's without any major issue (mysqldump into an .sql file)

 

But when I faced Bitbucket I found there are 3 methods to get the backups done. Due to my constrains, I chose "DIY backup" and adapted it to MySQL following several tips (including this one ).

 

Since I'm having 2 instances, I split the script usually called "bitbucket.diy-backup.vars.sh" into two new scripts called "bitbucket.diy-backup.vars_INSTANCE1.sh" and ""bitbucket.diy-backup.vars_INSTANCE2.sh" 

To allow using these files, I've modified the script called "bitbucket.diy-backup.sh" by commenting one line and adding the following code:

case "$1" in
INSTANCE1)
source "${SCRIPT_DIR}/common.sh" INSTANCE1
;;
INSTANCE2)
source "${SCRIPT_DIR}/common.sh" INSTANCE2
;;
*)
echo "Usage: $0 { INSTANCE1 | INSTANCE2 }
;;
esac

#source "${SCRIPT_DIR}/common.sh"

 

And consequently, I've modified the file common.sh to get this under consideration:

 

case "$1" in
INSTANCE1)
BACKUP_VARS_FILE=${BACKUP_VARS_FILE:-"${SCRIPT_DIR}"/bitbucket.diy-backup.vars_INSTANCE1.sh}
source "${SCRIPT_DIR}/common.sh" INSTANCE1
;;
INSTANCE2)
BACKUP_VARS_FILE=${BACKUP_VARS_FILE:-"${SCRIPT_DIR}"/bitbucket.diy-backup.vars_INSTANCE2.sh}
;;
*)
echo "Usage: $0 { INSTANCE1 | INSTANCE2 }
;;
esac

# BACKUP_VARS_FILE=${BACKUP_VARS_FILE:-"${SCRIPT_DIR}"/bitbucket.diy-backup.vars.sh}

 

All these "magic" is working perfectly ... but one detail: the size of the backups are increasing every time the backup is run ... and its mixing backups from INSTANCE1 into INSTANCE2 folder:

 

root@localhost: /backup/bitbucket_INSTANCE1/backup-archives # du -sh *
729M bitbucket-INSTANCE2_20190305-063002.tar.gz
2,2G bitbucket-INSTANCE2_20190305-125802.tar.gz

 

So I'm running out of disk, and I wish to know what might be wrong here.

 

Is there any bitbucket-instances-interaction playing here in the background?

 

Any help over there?

 

Thanks and warm regards

 

1 answer

0 votes
Alexis Robert
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 5, 2019

Hi @Altran , 

 

I'm not sure what the bitbucket.diy-backup.vars.sh does, but why don't you simply make a backup of all databases directly ? Something like 

mysqldump -u root -p --all-databases > alldb.sql

 

Otherwise, I would simply do a mysqldump of every database.

 

--Alexis

Altran March 5, 2019

Hi Alexis!

That was my very first approach ... but reading all the docs related to backup & restore I got scared about consistency ... so I decided to use the scripts provided.

 

My team is working on office hours, so I can perfectly schedule backups during nights and they should be consistent since nobody will be touching anything. Is this approach right? Or perhaps Bitbucket is always "doing something" that implies that the backup process must be strictly followed?

 

Thanks and warm regards,

Alexis Robert
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 5, 2019

In my experience, as long as no modification happens on the filesystem you should be good with only database backups.

For bitbucket of course you need to consider your code repositories  backup as well, but it should be handled separately.

 

Hope this helps, 

 

--Alexis

Altran March 7, 2019

Hi Alexis and all,

 

Finally I got two issues that were in place:

 

First, the instances weren't mixing, I just changed one variable that puts the name to the file compressed (tar.gz).

 

And second, the problem lies in both scripts for the variables ( "bitbucket.diy-backup.vars_INSTANCE1.sh" and "bitbucket.diy-backup.vars_INSTANCE2.sh"). I used the same original path, like this:

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

 

And it should be a completely different path, to avoid exactly the problem I faced (recursive backups):

BITBUCKET_BACKUP_ARCHIVE_ROOT=/bitbucket-backup-archives/INSTANCE1/

 

 

Finally, if someone wants to check how the solution is working two Jira's, two Confluence's and 2 BitBucket's running with MySQL in the same server, feel free to ping me.

 

Warm regards,

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events