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

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

DIY Bitbucket backup with postgreSQL fails with unable to lock database

I am using the DIY bitbucket backup script for backups.  My shared directory is on an NFS partition and the database is local.

When I run the backup script the rsync completes however I get an error that the system is unable to lock the database.  I am running Bitbucket version 5.4.6.


I am using PostgreSQL 9.4.  Any suggestions on how to get past this error?

Thanks in advance.


1 answer

0 votes

Hello Leslie,

Sounds like your DIY backup script is almost complete. We just need to get back this database dump error.

Can you please share how you're executing your Bitbucket database backup?

Once we have the above we can see what is causing this and what needs to be done to resolve the issue.

Stephen Sifers

Hello Stephen,


I am using pg_dump to backup the database.

Hello Leslie,

Could you please let me know the exact command string you are using with pg_dump?

(Please remove any usernames or passwords, just replace those with admin and password).

Stephen Sifers


suffix=`date +%Y -%m -%d`

# Backup the database

/bin/su - postgres -c /sw1/PostgreSQL/9.4/bin/pg_dumpall | bzip2 > ${prefix}/bitbucket.sq$suffix.bz2

Hello Leslie,

Thank you for sending me your pg_dump string. Reviewing what you sent, the pg_dumpall will attempt to backup every database within postgres at the time of execute. This may be the cause of your error. I would like to try only backing up the Bitbucket database and see what the result is that we get.

Could you please adjust your script to use a pg_dump string as follows:

pg_dump -F t bitbucketdb --no-synchronized-snapshots -f /path/folder

The above will backup only the bitbucket data you set along with creating a tar file of the database back within the path/folder you specify.

There is also additional instructions on creating DIY bitbucket backups at Using Bitbucket Server DIY Backup.

Please let us know the results of your database backup while only backing up bitbucket.

Stephen Sifers

Thanks for the update.  I will have to test the command off hours as there are users accessing bitbucket now.  I will let you know how I make out.


Like Stephen Sifers likes this

Hi Did this work out for you?

Suggest an answer

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

New improvements to user management in Bitbucket Cloud 👥

Hey Community! We’re willing to wager that quite a few of you not only use Bitbucket, but administer it too. Our team is excited to share that we’ll be releasing improvements throughout this month of...

3,755 views 10 16
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you