简体   繁体   中英

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 

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 .

I use this in my case with digital ocean...

pg_restore --clean -d 'postgresql://USER:qfdvr2ata7opidy4@HOST:PORT/DATABASE?sslmode=require' --jobs 2 database.dump

@Laurenz Albe's answer is spot on. Here is just an expanded version of the answer to include the SSL certs.

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM