Bitbucket DIY backup (with postgres) fails on second execution

Dominik Kaspar June 24, 2022

I followed the official documentation on the Bitbucket DIY Backup and managed to successfully run it to backup my PostgreSQL 14.3 database and the Bitbucket home. However, in a second execution the DIY script fails like this:

[bitbucket.diy-backup.sh:136 -> wait_for_bg_jobs][bb-001] ERROR: Database backup failed with status 1 (PID=25819)
[common.sh:138 -> unlock_bitbucket][bb-001] DEBUG: Running curl -L -s -f -u ******:****** http://localhost:7991/bitbucket/mvc/maintenance/lock?token=2ab330d0a9db44348d9c25d57e5f8d9fb102f421
[bitbucket.diy-backup.sh:139 -> cleanup_incomplete_backup][bb-001] DEBUG: Cleaning up after failed backup
[bitbucket.diy-backup.sh:0 -> main][bb-001] ERROR: Backing up Bitbucket failed
[common.sh:1 -> run_cleanup][bb-001] DEBUG: Running cleanup jobs...

When executing the pg_dump command alone, I see the problem: you cannot dump the database into the same directory (which already contains the first dump) a second time!

pg_dump -U bitbucketuser -h localhost --port=5432 -j 5 -Fd -d bitbucket --no-synchronized-snapshots -f /tmp/pg_dump
pg_dump: error: could not create directory "/tmp/pg_dump": File exists

My questions are now:

  1. Is there any easy option to configure the DIY backup to clean the previous dump?
  2. Why is Bitbucket still in maintenance mode after such an error!? It should get unlocked, but it's not! The Web UI keeps informing about "Performing backup - Backup is currently underway and shouldn't take long."

2 answers

0 votes
Piotr Biegun _Gitprotect_io_ July 6, 2022

If you are looking for a more automated Bitbucket backup and recovery solution you should check Gitprotect.io.

We have an official app listed on the Atlassian marketplace it works both for Bitbucket Cloud and DC. https://marketplace.atlassian.com/apps/1225728/gitprotect-io-backup-for-bitbucket?hosting=cloud&tab=overview


0 votes
Christian Glockner
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 6, 2022

Hi Dominik,

The DIY backup actually has a cleanup function defined in  https://bitbucket.org/atlassianlabs/atlassian-bitbucket-diy-backup/src/master/database-postgresql.sh#lines-52 by default it just runs an rm of the dump file - if that's not working as expected you may need to change or amend the function to delete the temporary file.

Cheers,

Christian

Premier Support Engineer

Atlassian

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events