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:
- Is there any easy option to configure the DIY backup to clean the previous dump?
- 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."