免密上传文件到FTP case

#!/bin/bash
mkdir -p /opt/backup/swiftlive/db/$(date +%Y%m%d)
#!/bin/bash
mkdir -p /opt/backup/swiftlive/db/$(date +%Y%m%d)
#pg_dump swiftlive_prod > /opt/backup/swiftlive/db/$(date +%Y%m%d)/swiftlive_prod_`date +%y-%m-%d_%H:%M:%S`.dmp
#pg_dump srs_spp > /opt/backup/swiftlive/db/$(date +%Y%m%d)/srs_spp_`date +%y-%m-%d_%H:%M:%S`.dmp
#pg_dump tigasedb_prod > /opt/backup/swiftlive/db/$(date +%Y%m%d)/tigasedb_prod_`date +%y-%m-%d_%H:%M:%S`.dmp
#pg_dump swiftlive_report > /opt/backup/swiftlive/db/$(date +%Y%m%d)/swiftlive_report_`date +%y-%m-%d_%H:%M:%S`.dmp




FTP_USER=databackup
FTP_PASS=fY6e1XZP2G3sCvw
FTP_IP=ftp.sin1.swiftserve.com
FTP_backup=/pub/postgresql/


Database_DIR=/opt/backup/swiftlive/db/
DataBak_DIR=$(date +"%Y%m%d")
OldData=$(date -d -30day +"%Y%m%d")
Yestday=$(date -d -1day +"%Y%m%d")


#delete old data
#if [  -d $Database_DIR$OldData ]; then
#cd $Database_DIR
#rm -rf $OldData
#fi
cp /opt/backup/swiftlive/db/$(date +%Y%m%d)/swiftlive_prod_$(date +"%y-%m-%d_00").dmp  $Database_DIR/$Yestday/


cd $Database_DIR/$Yestday/


ftp -v -n $FTP_IP << END
user $FTP_USER $FTP_PASS
type binary
cd $FTP_backup
mkdir $Yestday


#delete ftp old data
cd $FTP_backup$OldData
prompt
mdelete *
fi


cd $FTP_backup
rmdir $OldData


#delete $OldWeb
cd $FTP_backup$Yestday
mput *
#put $WebBakName
bye
END

你可能感兴趣的:(Shell)