hestiacp icon indicating copy to clipboard operation
hestiacp copied to clipboard

[Bug] v-restore-user is not restoring PostgreSQL db correctly

Open mbv opened this issue 2 years ago • 2 comments

Describe the bug

After restoring PostgreSQL database for user, db user password is not restored. (restoring log is without warnings/errors) After set password manually via changing password UI or cli. Db user can access to database, but it don't have permissions to get data from tables. And owner of tables is postgres.

Workaround:

  1. set manually password for db user
  2. a) delete tables and manually restore dump with specify user for psql b) execute for database(psql -d %database%): GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO %dbuser%;

Tell us how to replicate the bug

  1. Create new postgresql db for user a
  2. Add table with data
  3. Run v-backup-user for user a
  4. Delete this db for user a

ER: db and user db restored

AR: db user password is not restored, db user have not access to db tables and owner of tables is postgres

Which components are affected by this bug?

Database (MariaDB, PostgreSQL)

Hestia Control Panel Version

1.6.5

Operating system

Ubuntu 22.04

Log capture

No response

mbv avatar Jul 29 '22 08:07 mbv

Please submit a PR to fix the issue my knowledge with Postgress is currently terrible.

Importing is done here: https://github.com/hestiacp/hestiacp/blob/5a0a002197eab45157784eaa4b8900bd5d32923f/func/rebuild.sh#L854-L867

jaapmarcus avatar Sep 06 '22 12:09 jaapmarcus

Note: role is not permitted to log in after restore ALTER ROLE "$DBUSER" WITH LOGIN;

istiak101 avatar Jul 26 '23 01:07 istiak101