linux备份脚本

文件夹备份

[test@app-server ~]$ cat /home/test/uploadbak.sh
#!/bin/bash
file_dir=/upload
uploadbak_dir=/opt/uploadbak
bak_file=upload_`date +%Y%m%d%H%M`
# tar  everyday
#echo "begining of tar"
tar -zcf $uploadbak_dir/$bak_file.gz  $file_dir
# clear bak_file
#echo "clearing file.log"
#find $uploadbak_dir -mtime +30 -exec rm -rf {} \;

#end

数据库备份

[oracle@data-rac1 ~]$ cat /home/oracle/expdp_sql/expdp.sh
#!/bin/bash
export ORACLE_SID=test1
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db
export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin:$GRID_HOME/bin
expdp \'\/ as sysdba\' DIRECTORY=DMPDIR DUMPFILE=full_data-rac1_test$(date +%Y%m%d%H%M).dmp LOG=full_data-rac1_test$(date +%Y%m%d%H%M).log SCHEMAS=test,test1,test2,test3,test4

#定期删除dmp文件
cd /u02/oracle_DB
find -mtime +7 -name "full_data-rac1_test*"  -exec rm -f {} \;
# That's all

相关推荐