VPS自动备份上传FTP脚本
#!/bin/bash clear echo "" echo "*******************************************************************************************" echo "****************************Welcome using the Automated scripts****************************" echo "*******************************************************************************************" echo "" echo " ->1|backup ********* " echo "" echo "*******************************************************************************************" echo "" my_www=/home/wwwroot/ my_backup=/home/bakup/ my_data=/usr/local/mysql today=`date +%Y%m%d%H%M` FTP_IP=your IP FTP_USER=your name FTP_PASS=your password FTP_backup=your FTP_backup #back www backupCmbc () { cd ${my_www} tar czvf myWww-${today}.tar.gz default mv myWww-${today}.tar.gz ${my_backup} } #back data backupData () { cd ${my_data} tar czvf myData-${today}.tar.gz var mv myData-${today}.tar.gz ${my_backup} } put2ftp(){ DataBakName=myData-${today}.tar.gz WebBakName=myWww-${today}.tar.gz cd /home/bakup/ ftp -v -n $FTP_IP << EOF user $FTP_USER $FTP_PASS type binary passive cd $FTP_backup put $DataBakName put $WebBakName bye EOF } if [ "$1" != "" ] ; then if [ $1 == 1 ] ; then backupCmbc backupData put2ftp else echo "Changed Erroe,bye bye!" fi else read -p "Enter index number to select: " if [ "${REPLY}" == 1 ] ; then backupCmbc backupData put2ftp else echo "Changed Erroe,bye bye!" fi fi