Chat with us, powered by LiveChat
How to restore a database and take backup of database through shell?

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

Sharing

1 Comments

  1. 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

Leave your comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.