Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

./bitbucket.diy-backup.vars.sh: line 26: psql: command not found

Yogesh Mude
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 17, 2019

Team,

I tried to generate a bitbucket data center backup using a bitbucket Diy backup strategy.. I made the required changes to bitbucket.diy-backup.vars.sh file about bitbucket server URL, backup path, bitbucket home path, database port, server details etc..

Whenever i tried to run the below command getting error ./bitbucket.diy-backup.vars.sh: line 26: psql: command not found.

./bitbucket.diy-backup.sh

To check this error I logged into the database server and checked the database version using the below command and its returning correct result.

psql --version

Result : psql (PostgreSQL) 9.6.11

Any help will be appreciated.

 

1 answer

0 votes
Kurt Klinner
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 18, 2019

@Yogesh Mude 

 

Hi Yogesh

did not check the scripts yet, but any chance that sudo / su is used within switching to another users not having psql as element of his PATH settings

 

Can you output the PATH set within the script and or debug script by running it via bash -x?

 

Cheers

Kurt

Yogesh Mude
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 20, 2019

HI @Kurt Klinner 

Thanks for the response.

The error is getting in the ./bitbucket.diy-backup.vars.sh: line 26: psql: command not found. and below is the file data.

The scenario is ...I'm running the script from bitbucket server on which currently bitbucket resides so as per the error if psql command is not found on the bitbucket server then it's correct because we are using another server for PostgreSQL DB.

So could you please let me know what do i need to change in the below script code so that it will check the psql command to DB server but not in the bitbucket server.

#!/bin/bash

CURL_OPTIONS="-L -s -f"
INSTANCE_NAME=bitbucket

BITBUCKET_URL=http://localhost:7990
BITBUCKET_HOME=/bitbucket/
BITBUCKET_UID=atlbitbucket
BITBUCKET_GID=atlbitbucket

BACKUP_HOME_TYPE=rsync
BACKUP_DATABASE_TYPE=postgresql
BACKUP_ARCHIVE_TYPE=tar

BITBUCKET_BACKUP_USER=bitbucket-admin
BITBUCKET_BACKUP_PASS=internaladmin
BITBUCKET_BACKUP_EXCLUDE_REPOS=()

BITBUCKET_DB=bitbucketdb
POSTGRES_HOST=hostname
POSTGRES_USERNAME=bitbucketdbuser
export PGPASSWORD=bitbucketpass
POSTGRES_PORT=5432

# Make use of PostgreSQL 9.3+ options if available
psql_version="$(psql --version | awk '{print $3}')" // line 26
psql_majorminor="$(printf "%d%03d" $(echo "${psql_version}" | tr "." "\n" | head -n 2))"
if [[ ${psql_majorminor} -ge 9003 ]]; then
PG_PARALLEL="-j 5"
PG_SNAPSHOT_OPT="--no-synchronized-snapshots"
fi

BITBUCKET_BACKUP_ROOT=/bitbucket-backup
BITBUCKET_BACKUP_DB=${BITBUCKET_BACKUP_ROOT}/bitbucket-db/
BITBUCKET_BACKUP_HOME=${BITBUCKET_BACKUP_ROOT}/bitbucket-home/

BITBUCKET_BACKUP_ARCHIVE_ROOT=/bitbucket-backup-archives

# Used by the scripts for verbose logging. If not true only errors will be shown.
BITBUCKET_VERBOSE_BACKUP=TRUE

HIPCHAT_URL=https://api.hipchat.com
HIPCHAT_ROOM=
HIPCHAT_TOKEN=

KEEP_BACKUPS=0

 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events