The Private Cloud operations guide recommend using the restore-postgres.sh script to restore the postgres from a backup file post events like reinstallation.
It is likely that the script may fail with the following error during execution :
dropdb: database removal failed: ERROR: database "apigee" is being accessed by other users
This may not be a fatal error and may result in the data being added onto the existing db as opposed to dropping it and creating afresh - And that is the problem.
How can this be resolved ?
Because the pre-req for running the restore-postgres script is to have the postgres servers running, it is quite possible that there are active connections when dropdb is being executed from within the restore-postgres.sh script.
The above error occurs when there are any active connections. To terminate the connections, the following command can be used before running the restore-postgres.sh script :
select pg_terminate_backend(procpid) from pg_stat_activity where datname = '<database name>';
where database name needs to be replaced with apigee for the example outlined in the question.
This will prevent the dropdb failure.
User | Count |
---|---|
2 | |
1 | |
1 | |
1 | |
1 |