📄 1668.html
字号:
1<br>
785 (100%)<br>
1.py<br>
4086 (100%)<br>
2.py<br>
10680 (100%)<br>
a<br>
0 (100%)<br>
ip<br>
3956 (100%)<br>
./<br>
wrote 2900 bytes read 145499 bytes 576.34 bytes/sec<br>
total size is 2374927 speedup is 45.34<br>
<br>
对其它两个模块操作的命令分别为:<br>
<br>
/usr/local/bin/rsync -vzrtopg --delete --progress backup@202.99.11.120::web_user1 /backup/web_user1/ --password-file=/etc/rsync.pass<br>
<br>
/usr/local/bin/rsync -vzrtopg --delete --progress backup@202.99.11.120::web_user2 /backup/web_user2/ --password-file=/etc/rsync.pass<br>
<br>
可以将客户命令通过crontab -e命令来实现自动备份,如crontab -e:<br>
<br>
<br>
<br>
一些示例脚本<br>
这里这些脚本都是rsync网站上的例子:<br>
<br>
1、每隔七天将数据往中心服务器做增量备份<br>
<br>
#!/bin/sh<br>
<br>
# This script does personal backups to a rsync backup server. You will end up<br>
# with a 7 day rotating incremental backup. The incrementals will go<br>
# into subdirectories named after the day of the week, and the current<br>
# full backup goes into a directory called "current"<br>
# tridge@linuxcare.com<br>
<br>
# directory to backup<br>
BDIR=/home/$USER<br>
<br>
# excludes file - this contains a wildcard pattern per line of files to exclude<br>
EXCLUDES=$HOME/cron/excludes<br>
<br>
# the name of the backup machine<br>
BSERVER=owl<br>
<br>
# your password on the backup server<br>
export RSYNC_PASSWORD=XXXXXX<br>
<br>
<br>
########################################################################<br>
<br>
BACKUPDIR=`date +%A`<br>
OPTS="--force --ignore-errors --delete-excluded --exclude-from=$EXCLUDES<br>
--delete --backup --backup-dir=/$BACKUPDIR -a"<br>
<br>
export PATH=$PATH:/bin:/usr/bin:/usr/local/bin<br>
<br>
# the following line clears the last weeks incremental directory<br>
[ -d $HOME/emptydir ] || mkdir $HOME/emptydir<br>
rsync --delete -a $HOME/emptydir/ $BSERVER::$USER/$BACKUPDIR/<br>
rmdir $HOME/emptydir<br>
<br>
# now the actual transfer<br>
rsync $OPTS $BDIR $BSERVER::$USER/current<br>
<br>
2、备份至一个空闲的硬盘<br>
<br>
#!/bin/sh<br>
<br>
export PATH=/usr/local/bin:/usr/bin:/bin<br>
<br>
LIST="rootfs usr data data2"<br>
<br>
for d in $LIST; do<br>
mount /backup/$d<br>
rsync -ax --exclude fstab --delete /$d/ /backup/$d/<br>
umount /backup/$d<br>
done<br>
<br>
DAY=`date "+%A"`<br>
<br>
rsync -a --delete /usr/local/apache /data2/backups/$DAY<br>
rsync -a --delete /data/solid /data2/backups/$DAY<br>
<br>
3、对vger.rutgers.edu的cvs树进行镜像<br>
<br>
#!/bin/bash<br>
<br>
cd /var/www/cvs/vger/<br>
PATH=/usr/local/bin:/usr/freeware/bin:/usr/bin:/bin<br>
<br>
RUN=`lps x | grep rsync | grep -v grep | wc -l`<br>
if [ "$RUN" -gt 0 ]; then<br>
echo already running<br>
exit 1<br>
fi<br>
<br>
rsync -az vger.rutgers.edu::cvs/CVSROOT/ChangeLog $HOME/ChangeLog<br>
<br>
sum1=`sum $HOME/ChangeLog`<br>
sum2=`sum /var/www/cvs/vger/CVSROOT/ChangeLog`<br>
<br>
if [ "$sum1" = "$sum2" ]; then<br>
echo nothing to do<br>
exit 0<br>
fi<br>
<br>
rsync -az --delete --force vger.rutgers.edu::cvs/ /var/www/cvs/vger/<br>
exit 0<br>
<br>
FAQ<br>
Q:如何通过ssh进行rsync,而且无须输入密码?<br>
A:可以通过以下几个步骤<br>
<br>
1. 通过ssh-keygen在server A上建立SSH keys,不要指定密码,你会在~/.ssh下看到identity和identity.pub文件<br>
2. 在server B上的home目录建立子目录.ssh<br>
3. 将A的identity.pub拷贝到server B上<br>
4. 将identity.pub加到~[user b]/.ssh/authorized_keys<br>
5. 于是server A上的A用户,可通过下面命令以用户B ssh到server B上了<br>
e.g. ssh -l userB serverB<br>
这样就使server A上的用户A就可以ssh以用户B的身份无需密码登陆到server B上了。<br>
<br>
Q:如何通过在不危害安全的情况下通过防火墙使用rsync?<br>
A:解答如下:<br>
<br>
这通常有两种情况,一种是服务器在防火墙内,一种是服务器在防火墙外。无论哪种情况,通常还是使用ssh,这时最好新建一个备份用户,并且配置sshd仅允许这个用户通过RSA认证方式进入。 如果服务器在防火墙内,则最好限定客户端的IP地址,拒绝其它所有连接。如果客户机在防火墙内,则可以简单允许防火墙打开TCP端口22的ssh外发连接就ok了。<br>
<br>
Q:我能将更改过或者删除的文件也备份上来吗?<br>
A:当然可以:<br>
<br>
你可以使用如:rsync -other -options -backupdir = ./backup-2000-2-13 ...这样的命令来实现。<br>
这样如果源文件:/path/to/some/file.c改变了,那么旧的文件就会被移到./backup-2000-2-13/path/to/some/file.c,<br>
这里这个目录需要自己手工建立起来<br>
<br>
Q:我需要在防火墙上开放哪些端口以适应rsync?<br>
A:视情况而定<br>
<br>
rsync可以直接通过873端口的tcp连接传文件,也可以通过22端口的ssh来进行文件传递,但你也可以通过下列命令改变它的端口:<br>
<br>
rsync --port 8730 otherhost::<br>
或者<br>
rsync -e 'ssh -p 2002' otherhost:<br>
<br>
Q:我如何通过rsync只复制目录结构,忽略掉文件呢?<br>
A:rsync -av --include '*/' --exclude '*' source-dir dest-dir<br>
<br>
Q:为什么我总会出现"Read-only file system"的错误呢?<br>
A:看看是否忘了设"read only = no"了<br>
<br>
Q:为什么我会出现'@ERROR: invalid gid'的错误呢?<br>
A:rsync使用时默认是用uid=nobody;gid=nobody来运行的,如果你的系统不存在nobody组的话,就会出现这样的错误,可以试试gid = nogroup或者其它<br>
<br>
Q:绑定端口873失败是怎么回事?<br>
A:如果你不是以root权限运行这一守护进程的话,因为1024端口以下是特权端口,会出现这样的错误。你可以用--port参数来改变。<br>
<br>
Q:为什么我认证失败?<br>
A:从你的命令行看来:<br>
<br>
你用的是:<br>
> bash$ rsync -a 144.16.251.213::test test<br>
> Password:<br>
> @ERROR: auth failed on module test<br>
><br>
> I dont understand this. Can somebody explain as to how to acomplish this.<br>
> All suggestions are welcome.<br>
<br>
应该是没有以你的用户名登陆导致的问题,试试rsync -a max@144.16.251.213::test test<br>
<br>
<br>
</FONT><br>
</TD>
</TR>
<TR>
<TD colSpan=2><FONT
class=middlefont></FONT><BR>
<FONT
class=normalfont>全文结束</FONT> </TD>
</TR>
<TR>
<TD background="images/dot.gif" tppabs="http://www.linuxhero.com/docs/images/dot.gif" colSpan=2
height=10></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></DIV></TD>
<TD vAlign=top width="20%"
background="images/line.gif" tppabs="http://www.linuxhero.com/docs/images/line.gif" rowSpan=2>
<DIV align=center>
<table class=tableoutline cellspacing=1 cellpadding=4
width="100%" align=center border=0>
<tr class=firstalt>
<td noWrap background="images/bgline.gif" tppabs="http://www.linuxhero.com/docs/images/bgline.gif" colspan=2 height=21>
<font class=normalfont><b>所有分类</b></font></td>
</tr>
<tr class=secondalt> <td noWrap width=27%> <font class=normalfont>1:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type1.html" tppabs="http://www.linuxhero.com/docs/type1.html">非技术类</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>2:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type2.html" tppabs="http://www.linuxhero.com/docs/type2.html">基础知识</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>3:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type3.html" tppabs="http://www.linuxhero.com/docs/type3.html">指令大全</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>4:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type4.html" tppabs="http://www.linuxhero.com/docs/type4.html">shell</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>5:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type5.html" tppabs="http://www.linuxhero.com/docs/type5.html">安装启动</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>6:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type6.html" tppabs="http://www.linuxhero.com/docs/type6.html">xwindow</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>7:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type7.html" tppabs="http://www.linuxhero.com/docs/type7.html">kde</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>8:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type8.html" tppabs="http://www.linuxhero.com/docs/type8.html">gnome</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>9:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type9.html" tppabs="http://www.linuxhero.com/docs/type9.html">输入法类</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>10:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type10.html" tppabs="http://www.linuxhero.com/docs/type10.html">美化汉化</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>11:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type11.html" tppabs="http://www.linuxhero.com/docs/type11.html">网络配置</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>12:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type12.html" tppabs="http://www.linuxhero.com/docs/type12.html">存储备份</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>13:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type13.html" tppabs="http://www.linuxhero.com/docs/type13.html">杂项工具</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>14:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type14.html" tppabs="http://www.linuxhero.com/docs/type14.html">编程技术</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>15:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type15.html" tppabs="http://www.linuxhero.com/docs/type15.html">网络安全</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>16:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type16.html" tppabs="http://www.linuxhero.com/docs/type16.html">内核技术</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>17:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type17.html" tppabs="http://www.linuxhero.com/docs/type17.html">速度优化</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>18:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type18.html" tppabs="http://www.linuxhero.com/docs/type18.html">apache</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>19:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type19.html" tppabs="http://www.linuxhero.com/docs/type19.html">email</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>20:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type20.html" tppabs="http://www.linuxhero.com/docs/type20.html">ftp服务</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>21:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type21.html" tppabs="http://www.linuxhero.com/docs/type21.html">cvs服务</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>22:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type22.html" tppabs="http://www.linuxhero.com/docs/type22.html">代理服务</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>23:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type23.html" tppabs="http://www.linuxhero.com/docs/type23.html">samba</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>24:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type24.html" tppabs="http://www.linuxhero.com/docs/type24.html">域名服务</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>25:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type25.html" tppabs="http://www.linuxhero.com/docs/type25.html">网络过滤</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>26:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type26.html" tppabs="http://www.linuxhero.com/docs/type26.html">其他服务</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>27:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type27.html" tppabs="http://www.linuxhero.com/docs/type27.html">nfs</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>28:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type28.html" tppabs="http://www.linuxhero.com/docs/type28.html">oracle</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>29:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type29.html" tppabs="http://www.linuxhero.com/docs/type29.html">dhcp</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>30:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type30.html" tppabs="http://www.linuxhero.com/docs/type30.html">mysql</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>31:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type31.html" tppabs="http://www.linuxhero.com/docs/type31.html">php</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>32:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type32.html" tppabs="http://www.linuxhero.com/docs/type32.html">ldap</a></font></td> </tr> </table></td></tr> </table>
</DIV></TD></TR>
<TR vAlign=top>
<TD width="80%">
<DIV align=center><BR>
</DIV>
</TD></TR></TBODY></TABLE></TD></TR>
</TABLE></TD></TR>
</TABLE>
<TABLE cellSpacing=0 cellPadding=4 width="100%" bgColor=#eeeeee
border=0><TBODY>
<TR>
<TD width="50%">
<P><FONT class=middlefont>版权所有 © 2004 <A
href="mailto:bjchenxu@sina.com">linux知识宝库</A><BR>
违者必究. </FONT></P>
</TD>
<TD width="50%">
<DIV align=right><FONT class=middlefont>Powered by: <A
href="mailto:bjchenxu@sina.com">Linux知识宝库</A> Version 0.9.0 </FONT></DIV>
</TD></TR></TBODY></TABLE>
<CENTER></CENTER></TD></TR>
</TABLE></CENTER></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -