How to backup in postgresql

Tamilarasu P
Tamilarasu P used Ask the Experts™
on
Hi,

   how to take PostgreSQL backup in local driver and restore also.please tell me easiest way of backup & restore.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
backup
pg_dump dbname > outfile

Open in new window

restore
psql dbname < infile

Open in new window


https://www.postgresql.org/docs/9.1/static/backup-dump.html

HTH,
Dan

Author

Commented:
out file means backup file name?.if i enter any file name without extension and quotes ?

Commented:
Yes, outfile is the backup file name.

In Windows is something like D:\backups\dailybackup20170331.sql
In Linux is something like /home/backups/dailybackup20170331.sql
Become a Certified Penetration Testing Engineer

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

Author

Commented:
If I run this command "pg_dump Test > TodayBAckup"  in my postgresql
 I got a this error message "'NoneType' object has no attribute 'connection'"

Commented:
Do you have a database called Test?
That error basically says it could not find (or could not access due to insufficient rights) a database called "Test".

Author

Commented:
my database name was test

Commented:
test or Test?

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial