简体   繁体   English

pg_restore 使用 ssl 证书

[英]pg_restore using ssl certs

Can somebody help me in restoring postgres db using SSL certs.有人可以帮助我使用 SSL 证书恢复 postgres db。 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. pg_restore的参数不是连接字符串,而是要恢复的文件。 You use the -d option to specify the connection string:您使用-d选项指定连接字符串:

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. @Laurenz Albe 的回答很到位。 Here is just an expanded version of the answer to include the SSL certs.这只是答案的扩展版本,包括 SSL 证书。

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 .请参阅此处的文档。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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