Saturday, November 20, 2010

Use ZFS Snapshots to Backup and Restore Oracle DB without using Backup Mode

To backup 24*7 Oracle Production Databases, usually you have to put Oracle Database in backup mode before starting the backup and stop the backup mode at the end of backup; one side effect of Oracle Database running in backup mode is that heavy Redo Log Activities will increase the load to production sever and Redo Log will grow very rapidly at the same time; it also adds operational complexity if you want to create a point-of-time backup across Federated Databases, such as, multiple oracle databases used by SAP.

Snapshot technology has long been used by Storage Administrators to create instant point-of-time backup for storage file systems. As a technical breakthrough, Oracle has published My Oracle Support Notes Supported Backup, Restore and Recovery Operations using Third Party Snapshot Technologies [ID 604683.1], officially supports creating crash-consistent snapshot of Oracle Database, which is not in Backup Mode, as a valid Oracle Backup.

If you set up Oracle DB in ARCHIVELOG Mode and put all the Oracle Control Files, Data Files and Redo Log Files under a snapshot file system, such as NetApp Data ONTAP or Solaris/ZFS, which supports preserving the Write Ordering for each file under a snapshot, you can simply create a point-of-time snapshot from the file system as a valid Oracle Backup without putting Oracle DB in backup mode, and you can restore Oracle Database back to the snapshot time by restoring the backup snapshot. It is also true if you put Federated Oracle Databases under one parent snapshot file system, you can create a snapshot as a point-of-time backup for all the Federated Oracle DBs under the file system.

If you set up an Oracle Database running on OpenSolaris/ZFS, you can use ZFS Snapshot as Oracle Backup in the following way:

1. Create "oracledb" ZFS file system with the following sub-directories:
    -- controlfiles, storing all the oracle control files
    -- datafiles, storing all the oracle data files
    -- redologs, storing all the oracle archive redo log files;

2. As Oracle Database is running, you can simply create a
point-of-time snapshot using ZFS Snapshot Command:
    #zfs snapshot oracledb@12am-11-22-2010

3. Later, you simply restore Oracle DB back to snapshot time
using ZFS Rollback Snapshot Command:
    (1). Shutdown Oracle Database
    (2). Rollback "oracledb" ZFS to snapshot time
        #zfs rollback oracledb@12am-11-22-2010
    (3). Startup Oracle Database

No matter how large your oracle database, ZFS can create snapshot instantly and guarantee the write ordering of the created snapshot, this snapshot is called Crash-Consistent Snapshot/Image, which is equivalent to a Oracle DB Server being powered off by accident, when restarting Oracle DB, Oracle DB will do an automatic instance recovery and recover database to the last committed transaction recorded in redo log file. As you can see, how simple it is to backup and restore Oracle Database with ZFS Snapshot.

(Note: If you want to learn more about My Oracle Support Notes Supported Backup, Restore and Recovery Operations using Third Party Snapshot Technologies [ID 604683.1], you can read a good white paper Using Crash-Consistent Snapshot Copies as Valid Oracle Backups published by NetApp)