HOW to append pg_restore restoration log to file

10.5k Views Asked by At

I have tried multiple way to append log but not able to get.

for example.

pg_restore -U postgres -p5333 -d demodb < db_bkp_01_10_2019.dump >db_bkp_01_10_2019.log

pg_restore -U postgres -p5333 -d demodb < db_bkp_01_10_2019.dump 2>db_bkp_01_10_2019.log

pg_restore -U postgres -p5333 -d demodb < db_bkp_01_10_2019.dump 2&>db_bkp_01_10_2019.log

I want log related to restoration like what command executed on db while restoration.

2

There are 2 best solutions below

0
Amjad Shahzad On BEST ANSWER

You need to use the --verbose

Try this command

./pg_restore -U postgres -p 5333 -d demodb < db_bkp_01_10_2019.dump --verbose 2>db_bkp_01_10_2019.log

0
zhihong On

Took me sometime to figure this out, it works for me in psql 11 for log:

$pg_restore -h 127.0.0.1 -U user -p 5432 -d dbname -Fc import_data.sql>import.log 2>&1