可使用scp或mount的方式将备份文件传送到目标主机
#Mysql backup
#under of redhat linux
#Mysql data directory
mysqldatapath=/usr/local/mysql/data
#backup to the directory
mysqlbakdatapath=/home/mysqlbak
cd $mysqlbakdatapath
#create today directory
todaystr=`date -d "0 days ago" +%Y%m%d`
delbakdaystr=`date -d "3 days ago" +%Y%m%d`
rm -r $todaystr
mkdir $todaystr
todatafolder=$mysqlbakdatapath"/"$todaystr
echo "from: "$mysqldatapath
echo "to.. "$todatafolder
cp -a $mysqldatapath $todatafolder
cd $todatafolder
pwd
tar -czvf data.tar.gz data
echo "mysql data backuped"
rm -r $todatafolder"/data"
rm -r $mysqlbakdatapath"/"$delbakdaystr
cd $todatafolder
pwd
echo "scp..."
scp -r data.tar.gz [email protected]:/home/mysqlbak
cd $mysqlbakdatapath
#release tar
#tar -zxvf data.tar.gz
#job cron
# /etc/crontab
# add
#15 4 * * * root /home/mysqlbak/bak_linux_mysql_forday.sh
#pgrep crond
#pkill crond
#crond
-----------------
scp不带密码方法: