备份oracle并传输备份到windows服务器上

时间:2021-04-25 14:35:34

应客户的二逼需求,好好的ASM磁盘不放非要放到windows服务器的磁盘上,也是醉了。

首先需要在windows服务器上安装ftp server软件,我们这里用了FileZilla Server 。

配置好ftp服务器之后就开始写备份脚本吧

备份脚本如下:

#!/bin/sh
. /home/oracle/.bash_profile

bakdir=/home/oracle/bak/
Bak_Server_IP=192.168.56.2
ftpuname=oracle
ftppwd=oracle
remotedir=/
localdir=${bakdir}


rman target / >${bakdir}autorman.log<<EOF
configure channel device type disk rate 50m; #限速为多少根据具体情况决定
CONFIGURE RETENTION POLICY TO REDUNDANCY 1;
BACKUP AS COMPRESSED BACKUPSET DATABASE FORMAT '${bakdir}%d_%T_%U.bak';
delete obsolete;
YES
configure channel device type disk clear;
CONFIGURE RETENTION POLICY CLEAR;
EOF


starttime=`date +%y-%m-%d-%T`
echo "..................FTP Delete And Translate to $BAK_SERVER_IP...................." >${bakdir}autoftp.log
echo "..................start $starttime .............................................." >>${bakdir}autoftp.log

ftp -d -i -n >>${bakdir}autoftp.log 2>>${bakdir}autoftp.log <<EOF
open $Bak_Server_IP
user $ftpuname $ftppwd
bi
cd $remotedir
lcd $localdir
mput *.bak
bye
EOF

endtime=`date +%y-%m-%d-%T`
echo "..................end $endtime .............................................." >>${bakdir}autoftp.log
该脚本为压缩备份,冗余度为1,且自动删除过期备份