- apache重启!
- [root@IDC-D-2626 scripts]# cat apache.sh
- #/bin/sh
- /usr/local/apache2/bin/apachectl -f /vhost/Apache2Conf/httpd.conf -k graceful
- 备份脚本:
- [root@IDC-D-2626 scripts]# cat backupconf.sh
- #!/bin/sh
- echo "backup conf "
- Backup_date=`date +%y%m%d`
- HOST_IP=`/sbin/ifconfig eth0 | grep ***.***.*** |awk '{print $2}'|awk -F: '{print $2}'`
- cd /usr/vhome
- tar zcvf confcenter_${HOST_IP}_${Backup_date}.tar.gz Apache2Conf
- cp /usr/vhome/confcenter_${HOST_IP}_${Backup_date}.tar.gz /Backup_web_mount_point/conf
- if [ -e /Backup_web_mount_point/conf/confcenter_${HOST_IP}_${Backup_date}.tar.gz ] ; then
- rm -f /usr/vhome/confcenter_${HOST_IP}_${Backup_date}.tar.gz
- echo "confcenter_${HOST_IP}_${Backup_date}.tar.gz Backup finished" >>/home/liuxiaojie/confbackup.log
- else
- echo "confcenter_${HOST_IP}_${Backup_date}.tar.gz Backup failed" >>/home/liuxiaojie/confbackup.log
- fi
- ftp -n 10.11.12.182 >error 2>&1 <
- user linuxweb linuxweb
- bin
- prompt
- cd /***.***.***.104/conf
- lcd /Backup_web_mount_point/conf
- put confcenter_${HOST_IP}_${Backup_date}.tar.gz
- bye
- EOC
- find /Backup_web_mount_point/conf/ -mtime +7 | xargs rm -rf
没间隔一些日志,error_log文件有时候就会变的很大,甚至有时候撑满磁盘!清理该文件
- [root@IDC-D-2626 scripts]# cat cleanlog.sh
- #!/bin/sh
- echo "">/usr/local/apache2/logs/error_log
db备份脚本:将整个var压缩,上传到ftp空间下!
- [root@idc-d-2469 dbbackup]# cat mysqldbbackup.sh
- #!/bin/sh
- Backup_date=`date +%Y%m%d`
- cd /home/mysqldb
- tar zcvf /usr/dbbackup/db/148var_${Backup_date}.tar.gz ./var
- sh /usr/dbbackup/put.sh
- find /usr/dbbackup/db -mtime +6 | xargs rm -rf
- [root@idc-d-2469 dbbackup]# cat put.sh
- #!/bin/sh
- Backup_date=`date +%Y%m%d`
- ftp -n 10.4.2.246 >/usr/dbbackup/error 2>&1 <
- user linuxweb linuxweb
- bin
- prompt
- cd /dbbackup/***.***.***.148/
- lcd /usr/dbbackup/db
- put 148var_${Backup_date}.tar.gz
- bye
- EOC
另外一种情况:
这种情况:在客户端没有ftp命令, 系统采用了最小的安装方式:
我先在ftp server上创建一个用户:
useradd ungeosvnback
passwd ungeosvnback
查看vsftp已经安装:
[root@host009 ~]# rpm -qa | grep vsftp
vsftpd-2.0.5-24.el5
启动vsftp
/etc/init.d/vsftpd start
lsof -i :21 查看是否已经成功启动!
防火墙上添加规则使得客户端能够连接:
iptables -A INPUT -s 116.***.***.120 -j ACCEPT ##这里最好用内网地址,但我的机器上只有一个外网,只好用它了!
在客户端上安装ftp软件:
- tar jxvf ncftp-3.2.5-src.tar.bz2
- cd ncftp-3.2.5
- ./configure --prefix=/usr/local/ncftp
- make
- make install
- 即可安装!
我的脚本如下:
- [root@develop-res home]# cat backupsvn.sh
- #!/bin/sh
- find /home/bak/svnback*.tar.gz -mtime +1 | xargs rm -rf
- Backup_date=`date +%Y%m%d`
- cd /home
- tar zcvf /home/bak/svnback-${Backup_date}.tar.gz svnsource
- /usr/local/ncftp/bin/ncftpput -u ungeosvnback -p ungeosvnbackroot811026 -R 116.***.***.117 /home/ungeosvnback /home/bak/svnback-${Backup_date}.tar.gz
-u:指定连接的用户
-p:指定密码
-R:Recursive mode; copy whole directory trees.
116.***.***.117 :指定备份服务器的地址
/home/ungeosvnback :指定目的地址
/home/bak/svnback-${Backup_date}.tar.gz :指定要上传的文件
阅读(978) | 评论(0) | 转发(0) |