PostgreSQL – pg_basebackup: Could Not Set Compression Level -1

backupcompressionpostgresql-9.3

When trying to run pg_basebackup I received the following error message:

pg_basebackup: could not set compression level -1 (null)

using the -z option. I received a similar error message when trying -Z #.

Best Answer

I tried the command without a compression option and received this error message:

pg_basebackup: could not create file "/dir/names/base.tar": Permission denied

which revealed that the destination directory was not writable for the user. Changing permissions or ownership solved the problem.

Unfortunately, the original error message was not as informative as it could have been.