Linux自动备份脚本支持Centos Debian等
Linux自动备份脚本,支持Centos和Debian等操作系统(网站文件备份和数据库备份)
#!/bin/bash #==========================Compress Web to FTP======================== HOST=usavps WEB_DIR=/home/wwwroot/ BAK_DIR=/root/data_backup_dir FTP_HOST=8.8.8.8 FTP_PORT=21 FTP_USER=user FTP_PASS=passwd #====================================================================== timestamp=`date +%s`; today=`date +%Y%m%d`; BakName=Web_${HOST}_${today}_${timestamp}.tar.gz if [ ! -d $BAK_DIR ]; then mkdir -p $BAK_DIR; fi; #------------------------Tar Web to BAK_DIR dir--------------------------- tar zcvf $BAK_DIR/$BakName -C $WEB_DIR . find $BAK_DIR -mtime +7 -name '*.tar.gz' -exec rm -rf {} \; #------------------------Transfer Web to ftp--------------------------- ftp -v -n $FTP_HOST $FTP_PORT << END user $FTP_USER $FTP_PASS type binary prompt put $BAK_DIR/$BakName $BakName bye END
建议使用最新的备份脚本 http://www.gaaaa.com/notes/shell-auto-backup-to-ftp.html