根据我自己的服务器情况写的,有需要的朋友要注意根据自己的实际情况修改噢。
#!/bin/bash # backupmail.sh # 系统主要的服务有: # (1)Postfix # (2)DNS # (3)VSftp # (4)Apache # (5)Sshd # (6)Other #设置基本的系统环境: backdate=mail-`date +%Y%m%d` basedir=/home/upload/backup/ named=$basedir/named wwwd=$basedir/www postfixd=$basedir/postfix etcd=$basedir/etc #Backup postfix cp -a -f /etc/postfix/* $postfixd #Backup www cp -f /etc/httpd/conf/httpd.conf $wwwd #Backup named cp -a -f /var/named/* $named #Backup etc cp -f /usr/local/etc/clamd.conf $etcd cp -f /usr/local/etc/freshclam.conf $etcd cp -f /etc/crontab $etcd cp -f /etc/group* $etcd cp -f /etc/gshadow* $etcd cp -f /etc/host.conf $etcd cp -f /etc/hosts $etcd cp -f /etc/hosts.allow $etcd cp -f /etc/hosts.deny $etcd cp -f /etc/passwd* $etcd cp -f /etc/shadow* $etcd cp -f /etc/procmailrc $etcd #开始备份 cd /home/upload/backup tar -zpcf $backdate.tar.gz ./mail/* sleep 3s sync;sync;sync #FTP TO 172.16.86.253 id="upload" pw='upload' cd /home/upload/backup ftp -n 172.16.86.253 >>$basedir.ftp.log 2>&1 <<EOF user $id $pw bin cd backup put $backdate.tar.gz bye EOF #FTP to another server 172.16.86.5 ftp -n 172.16.86.5 >>$basedir.ftp.log 2>&1 <<EOF user $id $pw bin cd backup put $backdate.tar.gz bye EOF sync;sync
|
#设置每周日凌晨5点开始执行backupmail.sh备份shell
#vi /etc/crontab
#加入如下行
# Backup mail server
0 5 * * 0 root /home/upload/backup/backupmail.sh
阅读(1798) | 评论(0) | 转发(0) |