Oracleのバックアップスクリプト

いろいろなやり方があると思うが…とりあえずメモしておく。

 (未完成記事ですよ)

■backup_ORCL.sql

sqlを記述したファイルをviで作っておく。

set echo on
set feedback on
alter tablespace SYSAUX begin backup;
host cp -f "/u02/oradata/ORCL/sysaux01.dbf" /u02/orabackup/ORCL/hot_backup
host compress -f /u02/orabackup/ORCL/hot_backup/sysaux01.dbf"
alter tablespace SYSAUX end backup;
alter tablespace SYSTEM begin backup;
host cp -f "/u02/oradata/ORCL/systemORCL01.dbf" /u02/orabackup/ORCL/hot_backup
host compress -f /u02/orabackup/ORCL/hot_backup/systemORCL01.dbf"
alter tablespace SYSTEM end backup;
alter tablespace TOOLS begin backup;
host cp -f "/u02/oradata/ORCL/toolsORCL01.dbf" /u02/orabackup/ORCL/hot_backup
host compress -f /u02/orabackup/ORCL/hot_backup/toolsORCL01.dbf"
alter tablespace TOOLS end backup;
alter tablespace UNDOTBS begin backup;
host cp -f "/u02/oradata/ORCL/undoORCL01.dbf" /u02/orabackup/ORCL/hot_backup
host compress -f /u02/orabackup/ORCL/hot_backup/undoORCL01.dbf"
alter tablespace UNDOTBS end backup;
alter tablespace USERS begin backup;
host cp -f "/u02/oradata/ORCL/usersORCL01.dbf" /u02/orabackup/ORCL/hot_backup
host compress -f /u02/orabackup/ORCL/hot_backup/usersORCL01.dbf"
host cp -f "/u02/oradata/ORCL/usersORCL02.dbf" /u02/orabackup/ORCL/hot_backup
host compress -f /u02/orabackup/ORCL/hot_backup/usersORCL02.dbf"
host cp -f "/u02/oradata/ORCL/usersORCL03.dbf" /u02/orabackup/ORCL/hot_backup
host compress -f /u02/orabackup/ORCL/hot_backup/usersORCL03.dbf"
host cp -f "/u02/oradata/ORCL/usersORCL04.dbf" /u02/orabackup/ORCL/hot_backup
host compress -f /u02/orabackup/ORCL/hot_backup/usersORCL04.dbf"
alter tablespace USERS end backup;
alter database backup controlfile to '/u02/orabackup/ORCL/hot_backup/controlfile';
alter system archive log all;
alter system switch logfile;
exit