This series of posts will show you each week a new way to take a backup of your database. Hot backups, cold backups, using Oracle tool or just a simple script, you will see different ways to prepare for the worst...
Now, let's get into the subject. This first chapter will show you a very common way to take a backup using the BEGIN BACKUP command.
SQL> ALTER TABLESPACE users BEGIN BACKUP;
This command is avaliable since oracle 9i R2 - rel. 9204. What this does is that it flags the datafile headers "for backup" and performs a checkpoint on the tablespace so that no dirty buffer remains from modifications done before that point.
SQL> SELECT name, checkpoint_change#
FROM v$datafile_header;
The SCN of the datafile is frozen and all data modification in this mode will result in the affected data block to be written directly in the redo logs.
Note: Of course, using this mode will generate a lot of redo log activity!
You can then use a filesystem command to make a copy of the necessary files.
SQL> SELECT name FROM sys.v_$datafile;
SQL> SELECT member FROM sys.v_$logfile;
SQL> SELECT name FROM sys.v_$controlfile;
After you have taken your backup, you can put the tablespace back in normal mode with the END BACKUP command.
SQL> ALTER TABLESPACE users END BACKUP;
When putting the tablespace out of the BEGIN BACKUP mode, a record in the redo file will mark the end of the backup, and the "hot backup flag" in the concerned datafile headers is removed. The header SCN is written with the current one.
The backup is clean and can be restored using the archived redo logs.







