“permission denied” for pg_dump output file

前端 未结 3 1682
南旧
南旧 2021-02-13 22:05

i used below command to backup my database

sudo -u user_name pg_dump dbName -f /home ..../someWhere/db.sql

but it gives me this :

pg_

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-13 22:20

    It looks like your pg_dump is working fine, but it is having problems opening the output file as the sudo user. Just guessing, but, if you do the redirection as the user (presumably the one running the pg_dump command) id, that should do it, that is:

    sudo -u user_name pg_dump dbName > /home ..../someWhere/db.sql

    Using this technique your pg_dump will run as the postgres user (assuming that is who user_name is) and the file being written in /home... will be written using the permission of the user running the command (this user might have different permissions than the postgres user).

提交回复
热议问题