How to Backup and Restore PostgreSQL 9.3 Databases

In my previous blog post, I explained how to install PostgreSQL 9.3 on Oracle Linux. As a DBA, one of the first things we want to learn is how we can recover the database in case of a failure. So in this blog post, I’ll show how to backup and restore PostgreSQL databases in a server. We’ll backup PGDATA directory, so it’ll contain all databases in the instance (remember that PostgreSQL is a multitenant database).

PostgreSQL supports Write Ahead Log (WAL) mechanism like Oracle. So everything will be written to (redo)logs before they written into actual datafiles. So we will use a similar method to Oracle. We need to start “the backup mode”, copy the (data) files, and stop the backup mode, and add the archived logs to our backup. There are SQL commands for starting backup mode (pg_start_backup) and for stopping backup mode (pg_stop_backup), and we can copy the files using OS commands. Good thing is, since 9.1, PostgreSQL comes with a backup tool named “pg_basebackup”. It’ll do everything for us.

Book Review: Oracle Database 12c Backup and Recovery Survival Guide

Oracle Datasbase 12c Backup and Recovery Oracle Database 12c Backup and Recovery Survival Guide, written by Francisco Munoz Alvarez and Aman Sharma, is published by Packt. I’m one of the technical editors of the book and I can say that it’s well-written, easy-to-read, and covers all important topics about backup and recovery and provides the best practices.

Francisco Munoz Alvarez has over two decades of experience in consulting, support, implementation, and migration of Oracle products and he’s an Oracle ACE Director. Aman Sharma is an Oracle ACE, consultant and instructor. He holds a Master’s degree in Computer Applications and has been working with Oracle Database for over a decade.

Backup and Recovery Best Practices

Here are the best practices for backup and recovery for Oracle Databases. Although most of them are basic principles and can be applied to all Oracle versions, some of them are only valid for Oracle 10g and newer databases:

1) No need to explain: You must always run your DB in Archivelog mode!

2) Multiplex the controlfile at least 3 different locations. Be sure that they are located in different partitions (if possible different physical disks).

3) Multiplex the online redo log groups and members, be sure that putting them in different partitions (if possible different physical disks):

4) Take regular backups and verify that they work! Use validate command of RMAN or restore them to a test environment periodically: