Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pg_restore using ssl certs

Can somebody help me in restoring postgres db using SSL certs. I tried in below way but it didn't work

pg_restore "host=hostname user=username dbname=database_name sslcert=sslcert.crt sslkey=sslkey.key sslrootcert=sslroot.pem sslmode=verify-full" -f filename

It gives the below error

pg_restore: [archiver] could not open input file "host=hostname user=username dbname=database_name sslcert=sslcert.crt sslkey=sslkey.key sslrootcert=sslroot.pem sslmode=verify-full": No such file or directory 
like image 211
Panda Avatar asked Apr 13 '26 15:04

Panda


1 Answers

The argument of pg_restore is not the connection string, but the file to restore. You use the -d option to specify the connection string:

pg_restore -d "host=..." filename

You can specify any parameters that way. A more elaborate example would be:

pg_restore  --format=custom -d "port=5432 host=<hostname> 
user=<username> dbname=<dbname> sslrootcert=root.crt 
sslkey=server.key sslcert=server.crt sslmode=verify-ca" ../filename.dump -v

Please refer to the docs here.

like image 135
Laurenz Albe Avatar answered Apr 17 '26 01:04

Laurenz Albe