i_定时备份文件mysql
在cd /home下创建test
[root@oracle01 test]# find /kingsql/ -name mysqldump(mysqldump的绝对路径)
[root@oracle01 test]# cat test_database_backup.sh
/kingsql/database/mysql/bin/mysqldump -u root -poracle kingsqldb > /home/test/kinsqldb_$(date +%Y%m%d_%H%M%S).dmp
[root@oracle01 test]# crontab -e
*/1 * * * * /home/test/test_database_backup.sh
进入mysql 创建数据库准备把定是备份的数据导入
mysql> create database kingsqldb3
[root@oracle01 test]# mysql -uroot -poracle kingsqldb3<kinsqldb_20180718_180701.dmp
ii_定时备份文件oracle
oracle用户下进行(需要加入环境变量,否则crontab运行不了)
[oracle@oracle01 ~]$ vi oraclebf
PATH=$PATH:$HOME/bin
export PATH
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/11.2.4/dbhome_1
export ORACLE_SID=VDEDU # (??????????SID)
export ORACLE_TERM=xterm
export PATH=/usr/sbin:$PATH
export PATH=/u01/app/ogg:$ORACLE_HOME/bin:$PATH
export LD_LIBRARY_PATH=/u01/app/ogg:$ORACLE_HOME/lib:/lib:/usr/lib:$LD_LIBRARY_PATH
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
export NLS_DATE_FORMAT="yyyy-mm-dd HH24:MI:SS"
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
export LANG=C
export ORACLE_UNQNAME=VDEDU # ??
/u01/app/oracle/product/11.2.4/dbhome_1/bin/expdp system/oracle dumpfile=hr_`date +%Y%m%d_%H%M%S`.dmp logfile=hr_`date +%Y%m%d_%H%M%S`.log directory=d3 schemas=hr
crontab 定时备份(没两分钟一次)
[oracle@oracle01 ~]$ crontab -e
*/2 * * * * /home/oracle/oraclebf
iii_定时备份文件rman
acle@bogon ~]$ cat rman_
oracle.sh
TH=$PATH:$HOME/bin
export PATH
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/11.2.4/dbhome_1
export ORACLE_SID=VDEDU # (??????????SID)
export ORACLE_TERM=xterm
export PATH=/usr/sbin:$PATH
export PATH=/u01/app/ogg:$ORACLE_HOME/bin:$PATH
export LD_LIBRARY_PATH=/u01/app/ogg:$ORACLE_HOME/lib:/lib:/usr/lib:$LD_LIBRARY_PATH
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
export NLS_DATE_FORMAT="yyyy-mm-dd HH24:MI:SS"
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
export LANG=C
export ORACLE_UNQNAME=VDEDU
rman target / << EOF
run{
allocate channel c1 type disk;
backup database plus archivelog delete all input;
release channel c1;
}
EOF
[oracle@bogon ~]$ crontab -e
*/2 * * * * sh /home/oracle/
oracle.sh
*/5 * * * * sh /home/oracle/rman_
oracle.sh