“permission denied” for pg_dump output file

帅比萌擦擦* 提交于 2019-12-03 12:05:45

try pg_dump from psql command-line as below:

postgres=# \! pg_dump dbName -f /home ..../someWhere/db.sql

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).

Do it from psql command line like below

-bash-4.1$ pg_dump -Fp dbName -f /home ..../someWhere/db.sql &

-F selects the format of the output in which p is Output a plain-text SQL script file

and & at the end will run your backup in the background.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!