mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-10-10 16:33:23 +08:00
语法高亮,滚动条美化,设置页面调整
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
<h2 id="补充说明">补充说明</h2>
|
||||
<p><strong>rsync命令</strong> 是一个远程数据同步工具,可通过LAN/WAN快速同步多台主机间的文件。rsync使用所谓的“rsync算法”来使本地和远程两个主机之间的文件达到同步,这个算法只传送两个文件的不同部分,而不是每次都整份传送,因此速度相当快。 rsync是一个功能非常强大的工具,其命令也有很多功能特色选项,我们下面就对它的选项一一进行分析说明。</p>
|
||||
<h3 id="语法">语法</h3>
|
||||
<pre><code>rsync [OPTION]... SRC DEST
|
||||
<pre><code class="language-bash">rsync [OPTION]... SRC DEST
|
||||
rsync [OPTION]... SRC [USER@]host:DEST
|
||||
rsync [OPTION]... [USER@]HOST:SRC DEST
|
||||
rsync [OPTION]... [USER@]HOST::SRC DEST
|
||||
@@ -19,7 +19,7 @@ rsync [OPTION]... rsync://[USER@]HOST[:PORT]/SRC [DEST]</code></pre>
|
||||
<li>列远程机的文件列表。这类似于rsync传输,不过只要在命令中省略掉本地机信息即可。如:<code>rsync -v rsync://192.168.78.192/www</code></li>
|
||||
</ol>
|
||||
<h3 id="选项">选项</h3>
|
||||
<pre><code>-v, --verbose 详细模式输出。
|
||||
<pre><code class="language-bash">-v, --verbose 详细模式输出。
|
||||
-q, --quiet 精简输出模式。
|
||||
-c, --checksum 打开校验开关,强制对文件传输进行校验。
|
||||
-a, --archive 归档模式,表示以递归方式传输文件,并保持所有文件属性,等于-rlptgoD。
|
||||
@@ -83,11 +83,11 @@ rsync [OPTION]... rsync://[USER@]HOST[:PORT]/SRC [DEST]</code></pre>
|
||||
<h3 id="实例">实例</h3>
|
||||
<p><strong>SSH方式</strong></p>
|
||||
<p>首先在服务端启动ssh服务:</p>
|
||||
<pre><code>service sshd start
|
||||
<pre><code class="language-bash">service sshd start
|
||||
启动 sshd: [确定]</code></pre>
|
||||
<p><strong>使用rsync进行同步</strong></p>
|
||||
<p>接下来就可以在客户端使用rsync命令来备份服务端上的数据了,SSH方式是通过系统用户来进行备份的,如下:</p>
|
||||
<pre><code>rsync -vzrtopg --progress -e ssh --delete work@172.16.78.192:/www/* /databack/experiment/rsync
|
||||
<pre><code class="language-bash">rsync -vzrtopg --progress -e ssh --delete work@172.16.78.192:/www/* /databack/experiment/rsync
|
||||
work@172.16.78.192's password:
|
||||
receiving file list ...
|
||||
5 files to consider
|
||||
@@ -105,7 +105,7 @@ total size is 100663363 speedup is 1024.19</code></pre>
|
||||
<p>上面的信息描述了整个的备份过程,以及总共备份数据的大小。</p>
|
||||
<p><strong>后台服务方式</strong></p>
|
||||
<p>启动rsync服务,编辑<code>/etc/xinetd.d/rsync</code>文件,将其中的<code>disable=yes</code>改为<code>disable=no</code>,并重启xinetd服务,如下:</p>
|
||||
<pre><code>vi /etc/xinetd.d/rsync
|
||||
<pre><code class="language-bash">vi /etc/xinetd.d/rsync
|
||||
|
||||
#default: off
|
||||
# description: The rsync server is a good addition to an ftp server, as it \
|
||||
@@ -119,11 +119,11 @@ server = /usr/bin/rsync
|
||||
server_args = --daemon
|
||||
log_on_failure += USERID
|
||||
}</code></pre>
|
||||
<pre><code>/etc/init.d/xinetd restart
|
||||
<pre><code class="language-bash">/etc/init.d/xinetd restart
|
||||
停止 xinetd: [确定]
|
||||
启动 xinetd: [确定]</code></pre>
|
||||
<p>创建配置文件,默认安装好rsync程序后,并不会自动创建rsync的主配置文件,需要手工来创建,其主配置文件为“/etc/rsyncd.conf”,创建该文件并插入如下内容:</p>
|
||||
<pre><code>vi /etc/rsyncd.conf
|
||||
<pre><code class="language-bash">vi /etc/rsyncd.conf
|
||||
|
||||
uid=root
|
||||
gid=root
|
||||
@@ -141,10 +141,10 @@ read only = no
|
||||
exclude=test
|
||||
auth users=work</code></pre>
|
||||
<p>创建密码文件,采用这种方式不能使用系统用户对客户端进行认证,所以需要创建一个密码文件,其格式为“username:password”,用户名可以和密码可以随便定义,最好不要和系统帐户一致,同时要把创建的密码文件权限设置为600,这在前面的模块参数做了详细介绍。</p>
|
||||
<pre><code>echo "work:abc123" > /etc/rsyncd.passwd
|
||||
<pre><code class="language-bash">echo "work:abc123" > /etc/rsyncd.passwd
|
||||
chmod 600 /etc/rsyncd.passwd</code></pre>
|
||||
<p>备份,完成以上工作,现在就可以对数据进行备份了,如下:</p>
|
||||
<pre><code>rsync -avz --progress --delete work@172.16.78.192::www /databack/experiment/rsync
|
||||
<pre><code class="language-bash">rsync -avz --progress --delete work@172.16.78.192::www /databack/experiment/rsync
|
||||
|
||||
Password:
|
||||
receiving file list ...
|
||||
@@ -161,7 +161,7 @@ dd
|
||||
sent 172 bytes received 98276 bytes 17899.64 bytes/sec
|
||||
total size is 150995011 speedup is 1533.75</code></pre>
|
||||
<p>恢复,当服务器的数据出现问题时,那么这时就需要通过客户端的数据对服务端进行恢复,但前提是服务端允许客户端有写入权限,否则也不能在客户端直接对服务端进行恢复,使用rsync对数据进行恢复的方法如下:</p>
|
||||
<pre><code>rsync -avz --progress /databack/experiment/rsync/ work@172.16.78.192::www
|
||||
<pre><code class="language-bash">rsync -avz --progress /databack/experiment/rsync/ work@172.16.78.192::www
|
||||
|
||||
Password:
|
||||
building file list ...
|
||||
|
Reference in New Issue
Block a user