[root@redhat script]# cat back_web.sh #!/bin/bash #use scp not use password . so do it -->#ssh-keygen -t rsa --> scp -p .ssh/id_rsa.pub root@机器B的IP:/root/.ssh/authorized_keys #mkdir & go to backup ##################################### #back up web myPath="/var/web_bak" month=`date +%m` day=`date +%d` year=`date +%Y` hour=`date +%H` min=`date +%M` dirname=$year-$month-$day-$hour-$min echo $dirname if [ ! -d "$myPath" ]; then mkdir "$myPath" fi cd $myPath mkdir $dirname cd $dirname mkdir conf mkdir web mkdir db ##################################### #backup conf file cd /etc/httpd tar -zcvf $myPath/$dirname/conf/httpd.conf.tgz ./httpd.conf #backup web cd /usr/local/apache2/ tar -czf $myPath/$dirname/web/htdocs.tgz htdocs scp -r $myPath/$dirname root@192.168.10.7:/backup
本文出自 “技术人生” 博客,请务必保留此出处http://jesnridy.blog.51cto.com/5554751/1441399
原文地址:http://jesnridy.blog.51cto.com/5554751/1441399