How to restore a database and take backup of database through shell?
Postgresql
Using the following command, you can take a backup of your postgresql database.
# pg_dump -u -C -f backupfile.sql database_name
You can restore a pgsql database using the following command
# pg_restore -v -C -O -d database_name backupfile.sql.tar
Mysql
Using the following command you can take backup of a mysql database.
# mysqldump database_name > backup.sql
You can a restore mysql database using the following command
# mysql database_name




















Web Hosting Reviews said,
January 2, 2007 @ 4:29 pm
Following commands also useful to take backup and restore of simple (not contains large objects) postgresql database.
pg_dump mydb > db.out
To restore database
psql -d database -f db.out