Skip to Content
Menu
This question has been flagged
1 Reply
2604 Views

I have backup my database using the below code. 

filename="/var/pgdump/${db}_${date}.sql"
pg_dump ${db} -U openerp -w -h localhost -f $filename

When i restore the same database through the interface, it creates a new database.

When i run psql -U postgres -d check -1 -f database_20140611_2300080974977.sql this command, it shows error.

How can i restore database, which backup using above command?

Or any other solution(backup through command and restore through command or interface)?

 

Avatar
Discard
Author Best Answer

Backup database :- 

pg_dump --cluster 9.1/main --format=c old_database_name > new_database_name

Restore database :-

DB=new_database_name && createdb --cluster 9.1/main $DB && pg_restore --cluster 9.1/main --no-acl -O -d $DB <  backup_database_name.dump

Avatar
Discard