By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,401 Members | 793 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,401 IT Pros & Developers. It's quick & easy.

How to use pg_dump to backup a database?

P: 61
I want to backup and restore a database by comand line,
Acually I successed to do that but I have a problem in spacial status:

the database name: swt
schema name: public
the owner of this DB: swt_user

I executed the following comand, it worked and the backup done:

>pg_dump.exe -i -h localhost -p 5432 -U swt_user -F c -v -f d:\pg_backup\swt.backup -n public -w swt

although the command structure doesn't require the database name (swt), but it didn't work without it.

My issues:
1. I want to provide the password of the connected user
in this command, like following:
>pg_dump.exe -i -h localhost -p 5432 -U swt_user -F c -v -f d:\pg_backup\swt.backup -n public -W ******(the password)

because I want to execute the command automaticly,
is it possible?

2. I want to connect by the superuser (postgres) and
provide different schema names from different

3. Sometimes, when I execute the same command, it
doesn't work(access is denied) and I get an error
message that says:
(pg_dump is not a valid win32 application).

may someone help me and give me the optimal command
for each issues?

Best Regards
Apr 4 '11 #1
Share this Question
Share on Google+
1 Reply

Expert 100+
P: 700
Ad 1.
No, but you can create file .pgpass with all needed information

You should also ensure that postgres requires password for a user, see here

Ad 2. Not sure what do you mean. To connect as a superuser you can use
Expand|Select|Wrap|Line Numbers
  1. -U postgres

Ad 3.
Some windows issue? I'm not good at windows.
Apr 9 '11 #2

Post your reply

Sign in to post your reply or Sign up for a free account.