I recently run pg_dump to backup database using this command using user postgres : time pg_dump -j 4 -Fd -Z 3 db_profile -f /backup-nfs/

Previously, the size of backup-nfs was 100 G. The pg_dump worked fine. Then, the server admin increase it to 200 G. So I run Pg_dump again. But this time it is throwing out error : could not create directory "backup-nfs" : no such file or directory found.

I can create file and directory just as normal by using postgres account. But the pg_dump can't

What might be the possible cause ? I have checked the chown, its fine. I can also do a command like "ls-lah" on the directory and its working fine too.

Updates : maybe I need to share this.

So, then I try many pg_dump combinations.

  1. time pg_dump -U postgres -j 3 -F d -Z 3 -t tbl_test -f /backup/**somefolder**/db_profile.back db_profile -- does not work. ERROR : Could not open file '/var/lib/postgresql/backup/somefolder/backup.bak : No such file or directory

  2. time pg_dump -U postgres -F c -t profile db_profile -f **>** /backup-nfs/profile.bak -- technically, it works. I add directive ">". I thought it was working because of the directive. BUT, the file size is 0. So, it does not qualify to be working.

  3. I run again #2. -- ERROR : permission denied. I thought the ">" was the key, but it is not. Why does not it work ? It was just working a minute ago. Also, I have deleted the files from the previous backup.

  4. I try another command without -f, just the directive : pg_dump -h -Fc db_profile -t profile > /backup-nfs/dump.sql -- It works. The file is created too.

  5. I try another one : pg_dump -h -t jpt_non_pns -d db_profile -f /backup-nfs/dump_directive.bak -- It works as well. The file is created too.

Questions :

  1. why does it need different combination of parameters to work ? On my local server, it takes all combinations and still working fine.
  2. There was a command that works when executed the first time. Then it did not work the second time eventhough I have cleared the previous backup completely. Why does it behave like this?


1 Answer 1


The argument to the -f option is not an existing directory in which your backup will be created, but the name of the backup file or directory that does not exist yet and will be created by the backup. So try something like

pg_dump -F d -f /backup-nfs/db_profile.back db_profile

Here, db_profile is the database that is backed up, and /backup-nfs/db_profile.back is the directory that is created by the command and will contain the backup.

  • yes thanks for the advice. I will try it later on. But, why did the previous command work the first time the directory was created anyway?
    – padjee
    Sep 19, 2022 at 4:24
  • Sure, the directory gets created, but only if it doesn't yet exist and you have permissions on /. But then the directory will not contain your backup, but be your backup. Sep 19, 2022 at 4:27
  • pg_dump -F d -f /backup-nfs/**db_profile.back db_profile** The text after "/", what is this indicating? @LaurenzAlbe
    – padjee
    Sep 19, 2022 at 4:48
  • I have edited the answer to describe that. Sep 19, 2022 at 5:36
  • hi. i just tried it. still fail with the same error... @LaurenzAlbe
    – padjee
    Sep 19, 2022 at 7:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.