The goal of this article is to complete the process of automated Oracle database backups by executing a shell script, and to generate its compressed files in the current directory. The following steps are implemented:
1. Log on to the Linux system as an Oracle user.
2. Create a Database.srcipt file to generate some parameter information for the backup database and save it in the file database.parm.
This information is important for future recovery of the database, so in the process of physical backup, you need to save this information, you can also write some other important information in this script.
$vi Database.srcipt
Spool Database.parm
--This is the list of system parameters for the current backup database
SELECT * from V$parameter;
--This is the character set part parameter of the current backup database
SELECT * from props$;
--This is the current backup database data file storage location and name
SELECT * from V$datafile;
--This is the current backup database control file storage location and name
SELECT * from V$controlfile;
--This is the current backup database log file storage location and name
SELECT * from V$logfile;
--You can add some other important information here
--start to generate backup shell files, refer to backup.sh
Spool off
Spool backup.sh
Select ' CP ' | | name | | ' backup/' from V$datafile;
Select ' CP ' | | name | | ' backup/' from V$controlfile;
Select ' CP ' | | Member | | ' backup/' from V$logfile;
Spool off
Shutdown immediate
Exit
!
3. Modify the backup.sh file that was generated in the previous step and execute it to complete the operating system backup of the database file. For clarity, name this script file alterbackup.sh.
$vi alterbackup.sh
echo "This script completes the process of copying database data files, control files, log files to the current directory"
Cat Backup.sh|grep ' CP/' >c.sh
#该语句把backup. All statements in sh that start with "CP/" are extracted to generate a new file c.sh
RM backup.sh
MV C.sh backup.sh
chmod +x backup.sh
. backup.sh
#注意: Point number "." There is a space between the backup.sh and the