Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pg_dump windows command prompt invalid command

trying to using pg_dump to backup a postgres db

i connected through the command prompt and here is my command following this tutorial http://www.postgresqltutorial.com/postgresql-backup-database/

pg_dump -U postgres -W -F t lucz_2017 > X:\postgres_backup\lucz_backup.tar

it gives me an error

Invalid command \postgres_backup. Try \? for help.

what am I doing wrong?

the db name and paths are correct

windows 7 running this from the CMD

like image 368
ziggy Avatar asked Jul 28 '17 14:07

ziggy


People also ask

Where do I run pg_dump?

To backup one database, you can use the pg_dump tool. The pg_dump dumps out the content of all database objects into a single file. Second, execute the pg_dump program and use the following options to backup the dvdrental database to the dvdrental. tar file in the c:\pgbackup\ folder.

What is pg_dump in PostgreSQL?

pg_dump is a utility for backing up a PostgreSQL database. It makes consistent backups even if the database is being used concurrently. pg_dump does not block other users accessing the database (readers or writers). pg_dump only dumps a single database.

What is Pg_restore in Postgres?

pg_restore is a utility for restoring a PostgreSQL database from an archive created by pg_dump in one of the non-plain-text formats. It will issue the commands necessary to reconstruct the database to the state it was in at the time it was saved.

How do I create a DDL script in PostgreSQL?

Using PostgreSQL executablewith -s (–schema-only) and -t (–table) option to generate DDL of required tables. The option -s dictates that only DDL has to be generated and the option -t dictates that we want DDL of only tables to be generated.


2 Answers

You are running pg_dump from psql. Get out of psql and run pg_dump command from Windows Command prompt. pg_dump is its own executable, different from psql.

like image 142
Julia Leder Avatar answered Sep 28 '22 10:09

Julia Leder


This works for me in Windows PowerShell in Windows 10:

.\pg_dump.exe --username "yourUserName" --no-owner "yourDatabasName" >./filename.sql
like image 33
Spider Avatar answered Sep 28 '22 10:09

Spider