Postgres restore fails using DIY backup scripts

XMLWordPrintable

    • 1
    • Severity 3 - Minor

      Issue Summary

      It's not possible to restore the Postgres database using the atlassian-bitbucket-diy-backup.

      Steps to Reproduce

      1. Set up the backup as usual.
      2. Perform the restore.

      Expected Results

      The database is restored.

      Actual Results

      The below exception is thrown in the restore log:

      ubuntu@ip-10-229-129-160:~/atlassian-bitbucket-diy-backup$ ./bitbucket.diy-restore.sh bitbucket-20250320-022956
      2025-03-20 02:46:46 [common.sh:17 -> source][ip-10-229-129-160] DEBUG: Using vars file: './bitbucket.diy-backup.vars.sh'
      2025-03-20 02:46:46 [database-postgresql.sh:49 -> prepare_restore_db][ip-10-229-129-160] DEBUG: Running psql -U postgres -h localhost --port=5432 -d bitbucket -c 
      2025-03-20 02:46:46 [database-postgresql.sh:49 -> prepare_restore_db][ip-10-229-129-160] ERROR: Failed to connect to the database bitbucket
      2025-03-20 02:46:46 [database-postgresql.sh:49 -> prepare_restore_db][ip-10-229-129-160] ERROR: Cannot proceed because the database connection could not be established.
      Stack trace:
         [./database-postgresql.sh:49 -> prepare_restore_db]
          [./bitbucket.diy-restore.sh:0 -> main]
      

      Workaround

      The issue was introduced by the following change; 0816f06fdca97172f0086836b6fd246d438a163d.

      Remove the following line; database-postgresql.sh#lines-49:51.

          else
              error "Failed to connect to the database '${BITBUCKET_DB}'"
              bail "Cannot proceed because the database connection could not be established."
      

            Assignee:
            Moga
            Reporter:
            Moga
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: