linux 备份mysql并上传_Linux 网站目录和MySQL备份并上传FTP
#!/bin/bash
MYSQL_USER=root
MYSQL_PASS=
FTP_USER=
FTP_PASS=
FTP_IP=
FTP_backup=backup
WEB_DATA=/home/wwwroot
DataBakName=Data_$(date +”%Y%m%d”).tar.gz
WebBakName=Web_$(date +”%Y%m%d”).tar.gz
OldData=Data_$(date -d -3day +”%Y%m%d”).tar.gz
OldWeb=Web_$(date -d -3day +”%Y%m%d”).tar.gz
rm -rf /home/backup/Data_$(date -d -3day +”%Y%m%d”).tar.gz /home/backup/Web_$(date -d -3day +”%Y%m%d”).tar.gz
cd /home/backup
for db in `/usr/local/mysql/bin/mysql -u$MYSQL_USER -p$MYSQL_PASS -B -N -e ‘SHOW DATABASES’ | xargs`; do
(/usr/local/mysql/bin/mysqldump -u$MYSQL_USER -p$MYSQL_PASS ${db} | gzip -9 – > ${db}.sql.gz)
done
tar zcPf /home/backup/$DataBakName /home/backup/*.sql.gz
rm -rf /home/backup/*.sql.gz
tar zcf /home/backup/$WebBakName $WEB_DATA
ftp -v -n $FTP_IP << END
user $FTP_USER $FTP_PASS
type binary
cd $FTP_backup
delete $OldData
delete $OldWeb
put $DataBakName
put $WebBakName
bye
END
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎勵來咯,堅持創(chuàng)作打卡瓜分現(xiàn)金大獎總結(jié)
以上是生活随笔為你收集整理的linux 备份mysql并上传_Linux 网站目录和MySQL备份并上传FTP的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: ida 反编译 linux bin,使用
- 下一篇: aix vnc oracle,请问如何配