微智科技网
您的当前位置:首页oracle服务器自动备份

oracle服务器自动备份

来源:微智科技网

oracle服务器自动备份

1、

1
2
3
4
5
6
$sqlplus  /nolog
$conn sys  /as  sysdba
SQL> create directory expdata as  '/home/oracle/oraclebak' ;
Directory created.
SQL> grant  read ,write on directory expdata to public;  
SQL>  exit

2、


$mkdir /home/oracle/oraclebak

3、创建备份角本,给执行权限 

----------------------

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
  #!/bin/sh  
       
     export  ORACLE_BASE= /home/oracle/app/oracle 
     export  ORACLE_HOME=$ORACLE_BASE /db11g
     export  ORACLE_SID=X
     export  PATH=$PATH:$HOME /bin :$ORACLE_HOME /bin  
       
     export  DATA_DIR= /home/oracle/oraclebak  
    
     export  DEL_TIME=` date  -d  "5 days ago"  +%Y%m%d`  
     export  BAKUP_TIME=` date  +%Y%m%d%H%M%S`  
     echo  "Starting bakup..."  
     echo  "Bakup file path $DATA_DIR/$BAKUPTIME.dmp"  
     expdp system/ '密码'  directory=expdata dumpfile=$BAKUP_TIME.dmp full=y logfile=$BAKUP_TIME.log
       
     echo  "Delete the file bakup before 5 days..."  
     rm  -rf $DATA_DIR/$DEL_TIME*.dmp   $DATA_DIR/$DELTIME*.log  
     echo  "Delete the file bakup successfully. "

4、

1
$ crontab  -e
1
2
#!/bin/sh  
00 3 * * *  /home/oracle/orale .bak.sh


本文出自 “” 博客,请务必保留此出处

因篇幅问题不能全部显示,请点此查看更多更全内容