Paul Labis: This is a personal blog where everyone can read my experiences, ideas and thoughts about programming, latest gadgets and other information technology related topics, lifestyle and many other stuff I would like to share to the public.

How to Backup and Restore PostgreSQL Database

There is an easy way to create backup file and restore your current PostgreSQL database using the Linux terminal. I am not sure though if this is the easiest way.

As of the moment I am writing this article, I used the following command to backup and restore my database. 

Using pg_dump and psql will make your life easier. Below are the terminal command I use to backup and restore my database.
  • Backup : pg_dump -U {user_name} {database_name} -f {backup_file_name}
  • Restore : psql -U {user_name} -d {database_name} -f {backup_file_name}
If you are getting an error:

Recover Ubuntu Grub2 After Windows Installation

A month ago I decided to dual-boot my laptop with windows 7 and Ubuntu 10.04 version as my main operating system. So I first installed Ubuntu 10.04 then Windows 7 afterwards. After installing Windows 7, ubuntu distribution isn't accessible. I am not sure but I think Windows installation might have wiped out Ubuntu grub.

To be able to recover Grub2 menu along with the option to select either which operating system you want to use, I did the following recovery steps below.
  1. Boot from Ubuntu Live CD - any Ubuntu distribution is okay to use for as long as you get access to linux terminal or bash shell.