i would like to take backup and restore of my postgresql database automatically.
- take backup automatically from postgresql with cron trigger in windows pc
- later i will do restore when ever it required.
i have below bat commands to take back up of my database
F:
cd F:\softwares\postgresql-12.1-3-windows-x64-binaries\pgsql\bin
pg_dump.exe -U postgres -s fuelman > E:\fuel_man_prod_backup\prod.sql
cmd /k
but i am getting
pg_dump: error: too many command-line arguments (first is "-s")
also i need to take both schema structure with data.
Edit :- removed password -W
CodePudding user response:
"Too many command line" probably is due to -W option; the string "postgres" after -W is interpreted as db name, so following -s gives error. Anyway, when running pg_dump from a script you must not use -W; use .pgpass file or set PGPASSWORD environment variable (look at pg_dump: too many command line arguments for more details).
As for Frank Heikens comment, if you need to dump both object definition and data, avoid -s option. pg_dump documentation is quite clear.