-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathrsync.html
130 lines (130 loc) · 6.01 KB
/
rsync.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>3.1. sync 命令</title>
<link rel="stylesheet" href="/stylesheets/master.css" type="text/css">
<link rel="stylesheet" href="/stylesheets/syntax.css" type="text/css">
<link rel="stylesheet" href="/docbook/includes/css/docbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.72.0">
<link rel="start" href="index.html" title="BCP (Basic)">
<link rel="up" href="mirror.html" title="3. 镜像,数据同步">
<link rel="prev" href="mirror.html" title="3. 镜像,数据同步">
<link rel="next" href="unison.html" title="3.2. unison 命令">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<script language="javascript" type="text/javascript" src="/docbook/includes/js/header.js"></script><script language="javascript"> write_header("/docbook"); </script><div class="navheader">
<table width="100%" summary="Navigation header">
<tr><th colspan="3" align="center">3.1. sync 命令</th></tr>
<tr>
<td width="20%" align="left">
<a accesskey="p" href="mirror.html"><img src="/docbook/includes/images/docbook/prev.png" alt="上一页"></a> </td>
<th width="60%" align="center">3. 镜像,数据同步</th>
<td width="20%" align="right"> <a accesskey="n" href="unison.html"><img src="/docbook/includes/images/docbook/next.png" alt="下一页"></a>
</td>
</tr>
</table>
<hr>
</div>
<div class="sect2" lang="zh-cn">
<div class="titlepage"><div><div><h3 class="title">
<a name="rsync"></a>3.1. sync 命令</h3></div></div></div>
<div class="toc"><dl>
<dt><span class="sect3"><a href="rsync.html#idp4489248">3.1.1. 介绍</a></span></dt>
<dt><span class="sect3"><a href="rsync.html#idp4490864">3.1.2. A Simple Example</a></span></dt>
<dt><span class="sect3"><a href="rsync.html#idp4495360">3.1.3. Rsync over SSH</a></span></dt>
</dl></div>
<p>
实话实说:我现在主要是用 unison ,已经基本上不用 sync 命令了。因为我更看中 unison 的双向同步,以及 unison 对上次同步状态的保持,同步速度快。
</p>
<p>
2002年写的 sync 命令介绍,还是留着吧,有时候也需要单向数据备份吧。
</p>
<div class="sect3" lang="zh-cn">
<div class="titlepage"><div><div><h4 class="title">
<a name="idp4489248"></a>3.1.1. 介绍</h4></div></div></div>
<p>
Rsync is a tool for archiving and file transfer that employs a clever algorithm to minimize data transfers.
If two files are almost identical, only the differences will be transported over the network.
</p>
<p>
Rsync 适合进行双机备份。
</p>
</div>
<div class="sect3" lang="zh-cn">
<div class="titlepage"><div><div><h4 class="title">
<a name="idp4490864"></a>3.1.2. A Simple Example</h4></div></div></div>
<p>
The following command, will sync local directory, public-html, to the remote server 10.0.0.x.
i.e., copy date from local client to remote server.
</p>
<pre class="screen">
$ <span><strong class="command">rsync -a public_html/ 10.0.0.x:public_html</strong></span>
</pre>
<p>
The following command, will sync directory, public-html, from the remote server 10.0.0.x to the local client.
i.e., copy data from remote server to local client.
</p>
<pre class="screen">
$ <span><strong class="command">rsync -a 10.0.0.x:public_html/ public_html</strong></span>
</pre>
<p>
考虑到安全性,和实现自动登陆以有利于自动同步数据,参见下节介绍的 Rsync over SSH 和 Passwordless SSH Authentication。
</p>
</div>
<div class="sect3" lang="zh-cn">
<div class="titlepage"><div><div><h4 class="title">
<a name="idp4495360"></a>3.1.3. Rsync over SSH</h4></div></div></div>
<p>
One of the best feature of rsync is that it works over multiple transport protocols.
By default, rsync uses rsh to do its work, but since rsh is deprecated in the Queen's Physics Department,
we will use the secure shell (ssh) as the underlying transport mechanism, thus providing for secure, encrypted file transfers.
</p>
<pre class="screen">
$ <span><strong class="command">rsync -av public_html/ -e ssh 10.0.0.x:public_html</strong></span>
</pre>
<p>
A more complicate sample:
</p>
<pre class="screen">
<span><strong class="command">$ /usr/bin/rsync -e ssh -avzp --exclude "*.journal" --exclude "dnscache/" --exclude "dnscachex/" \
--delete /home remotehost:/var/backups/mycomputer/ </strong></span>
</pre>
<p>
Archive and mirror /home onto the remotehost's /var/backups/mycomputer directory and keep all the permissions.
Note that *.journal are the journal files on ext3 partitions and don't need to be copied
and the --delete flag can be omitted in case you want to keep old file that have been deleted
archived on the remotehost side permenently.
</p>
</div>
</div>
<table class="copyright" border="0" cellpadding="0" cellspacing="0" width="100%">
<col width="33%">
<col width="33%">
<col width="33%">
<tr>
<td></td>
<td align="center" valign="center"></td>
<td align="right" valign="center"><p class="copyright">
Copyright © 2006 <a href="http://www.worldhello.net/doc/"><b>WorldHello 开放文档之源</b> 计划</a></p></td>
</tr>
</table>
<div class="navfooter">
<hr>
<table width="100%" summary="Navigation footer">
<tr>
<td width="40%" align="left">
<a accesskey="p" href="mirror.html"><img src="/docbook/includes/images/docbook/prev.png" alt="上一页"></a> </td>
<td width="20%" align="center"><a accesskey="u" href="mirror.html"><img src="/docbook/includes/images/docbook/up.png" alt="上一级"></a></td>
<td width="40%" align="right"> <a accesskey="n" href="unison.html"><img src="/docbook/includes/images/docbook/next.png" alt="下一页"></a>
</td>
</tr>
<tr>
<td width="40%" align="left" valign="top">3. 镜像,数据同步 </td>
<td width="20%" align="center"><a accesskey="h" href="index.html"><img src="/docbook/includes/images/docbook/home.png" alt="首页"></a></td>
<td width="40%" align="right" valign="top"> 3.2. unison 命令</td>
</tr>
</table>
</div>
<script language="javascript" type="text/javascript" src="/docbook/includes/js/footer.js"></script><script language="javascript"> write_footer("/docbook"); </script>
</body>
</html>