TransWikia.com

PostgreSQL pg_restore: How do I save script report to a txt file?

Database Administrators Asked on December 24, 2021

I need to run pg_restore on my PC with Windows CMD to restore a dump to a remote DB. I need to save the running report of the pg_restore into a file, to make sure the restoration ran as expected. Below is the pg_restore command I ran.

pg_restore.exe --host=10.10.10.2 --port=5432 --username=postgres 
               --dbname=mytargetdb --verbose --single-transaction "AT5.DUMP"

It turned out that:

  • Putting > report.txt in the end of the pg_restore command does not render error, but nothing got written to the textfile.
  • Using the --file=report.txt throws "error: options -d/–dbname and -f/–file cannot be used together"

The restoration was actually successful. But copy-paste from the cmd windows is not an option as the resulting report was long enough so the cmd only shows some hundreds of the last line of the report, and not the most from earlier lines.

So how should I do that?

My environment:

  • My PC: pg_restore version 12.2 on Windows 10 Pro
  • Target server: PostgreSQL 9.6 on Windows Server 2008 R2 Data Center

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP