Search code examples
databasepostgresqlcommand-linebackuppg-dump

"permission denied" for pg_dump output file


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_dump: [archiver] could not open output file "/home ..../someWhere/db.sql": Permission denied

after googling this issue i find that i must backup my data under the /tmp path , but doesn't work

how can i resolve this issue ?

thanks in advance,


i am using Ubuntu 12.04 lts


Solution

  • try pg_dump from psql command-line as below:

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