<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>fengcool.com &#187; backup</title>
	<atom:link href="http://www.fengcool.com/tag/backup/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.fengcool.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Wed, 25 Jan 2012 19:09:58 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Rsync server and client &#8211; backup your server files</title>
		<link>http://www.fengcool.com/2009/07/rsync_server_and_client_backup_server_file/</link>
		<comments>http://www.fengcool.com/2009/07/rsync_server_and_client_backup_server_file/#comments</comments>
		<pubDate>Thu, 30 Jul 2009 17:28:53 +0000</pubDate>
		<dc:creator>rick</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[rsync]]></category>
		<category><![CDATA[rsync client]]></category>
		<category><![CDATA[rsync server]]></category>

		<guid isPermaLink="false">http://www.fengcool.com/?p=112</guid>
		<description><![CDATA[rsync can synchronizes files and directories from one server to another. It's perfectly for backup or create a mirror site purpose.]]></description>
			<content:encoded><![CDATA[<p>rsync can synchronizes files and directories from one server to another. It&#8217;s perfectly for backup or create a mirror site purpose.</p>
<p>This tutorial shows you step by step to create a rsync server and client server.</p>
<p>First of all, you must have rsync installed. For fedora, rsync should be included by default. If you don&#8217;t have it, run</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">yum <span style="color: #c20cb9; font-weight: bold;">install</span> rsync</pre></td></tr></table></div>

<p><strong>Setup rsync server</strong></p>
<p>Create rsync configuration file:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>etc
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> rsyncd
<span style="color: #7a0874; font-weight: bold;">cd</span> rsyncd
<span style="color: #c20cb9; font-weight: bold;">touch</span> rsyncd.conf
<span style="color: #c20cb9; font-weight: bold;">touch</span> rsyncd.motd
<span style="color: #c20cb9; font-weight: bold;">touch</span> rsyncd.user
<span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #000000;">600</span> rsyncd.user</pre></td></tr></table></div>

<p>edit rsyncd.user file and create username and password:<br />
vi /etc/rsyncd/rsyncd.user</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">my_rsync_user_1:user_1_password</pre></td></tr></table></div>

<p>edit rsyncd.conf file:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>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
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">pid <span style="color: #007800;"><span style="color: #c20cb9; font-weight: bold;">file</span></span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run<span style="color: #000000; font-weight: bold;">/</span>rsyncd.pid
<span style="color: #007800;">port</span>=<span style="color: #000000;">873</span>
<span style="color: #007800;">uid</span>=root
<span style="color: #007800;">gid</span>=root
use <span style="color: #007800;"><span style="color: #c20cb9; font-weight: bold;">chroot</span></span>=<span style="color: #c20cb9; font-weight: bold;">yes</span>
<span style="color: #c20cb9; font-weight: bold;">read</span> <span style="color: #007800;">only</span>=<span style="color: #c20cb9; font-weight: bold;">yes</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># limit access to LANS</span>
hosts <span style="color: #007800;">allow</span>=192.168.2.0<span style="color: #000000; font-weight: bold;">/</span>255.255.255.0   <span style="color: #666666; font-style: italic;">#default, listen to lan server</span>
host <span style="color: #007800;">deny</span>=<span style="color: #000000; font-weight: bold;">*</span>
&nbsp;
max <span style="color: #007800;">connections</span>=<span style="color: #000000;">5</span>
motd <span style="color: #007800;"><span style="color: #c20cb9; font-weight: bold;">file</span></span>=<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>rsyncd<span style="color: #000000; font-weight: bold;">/</span>rsyncd.motd
&nbsp;
log <span style="color: #007800;">format</span>=<span style="color: #000000; font-weight: bold;">%</span>t<span style="color: #000000; font-weight: bold;">%</span>a<span style="color: #000000; font-weight: bold;">%</span>m<span style="color: #000000; font-weight: bold;">%</span>f<span style="color: #000000; font-weight: bold;">%</span>b
syslog <span style="color: #007800;">facility</span>=local3
<span style="color: #007800;">timeout</span>=<span style="color: #000000;">300</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">&#91;</span>profile_1<span style="color: #7a0874; font-weight: bold;">&#93;</span>          <span style="color: #666666; font-style: italic;">#profile name</span>
path = <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>backup<span style="color: #000000; font-weight: bold;">/</span>directory
ignore errors
<span style="color: #c20cb9; font-weight: bold;">read</span> only = <span style="color: #c20cb9; font-weight: bold;">false</span>
list = <span style="color: #c20cb9; font-weight: bold;">false</span>
hosts allow = 66.66.66.66   <span style="color: #666666; font-style: italic;">#listen to client server which use public ip</span>
hosts deny = 0.0.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">32</span>
auth <span style="color: #c20cb9; font-weight: bold;">users</span> = my_rsync_user_1
secrets <span style="color: #c20cb9; font-weight: bold;">file</span> = <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>rsyncd<span style="color: #000000; font-weight: bold;">/</span>rsyncd.user
&nbsp;
<span style="color: #666666; font-style: italic;">#[profile_1]          #another profile name</span>
<span style="color: #666666; font-style: italic;">#path = /path/to/backup/directory/2</span>
<span style="color: #666666; font-style: italic;">#ignore errors</span>
<span style="color: #666666; font-style: italic;">#read only = false</span>
<span style="color: #666666; font-style: italic;">#list = false</span>
<span style="color: #666666; font-style: italic;">#hosts allow = 88.88.88.88   #listen to client server which use public ip</span>
<span style="color: #666666; font-style: italic;">#hosts deny = 0.0.0.0/32</span>
<span style="color: #666666; font-style: italic;">#auth users = my_rsync_user_2</span>
<span style="color: #666666; font-style: italic;">#secrets file = /etc/rsyncd/rsyncd.user</span></pre></td></tr></table></div>

<p>Next, create init start up script<br />
vi /etc/init.d/rsyncd</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>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
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Startup script for rsyncd daemon</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># chkconfig: 35 90 10</span>
<span style="color: #666666; font-style: italic;"># description: Server data for sync to other server</span>
<span style="color: #666666; font-style: italic;"># processname rsync</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Source function library</span>
. <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>rc.d<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>functions
&nbsp;
<span style="color: #007800;">prog</span>=rsync
<span style="color: #007800;">conf</span>=<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>rsyncd<span style="color: #000000; font-weight: bold;">/</span>rsyncd.conf
&nbsp;
<span style="color: #000000; font-weight: bold;">case</span> <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #000000; font-weight: bold;">in</span>
    start<span style="color: #7a0874; font-weight: bold;">&#41;</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;Starting rsync daemon: &quot;</span>
        daemon <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$prog</span> <span style="color: #660033;">--daemon</span> <span style="color: #660033;">--config</span>=<span style="color: #007800;">$conf</span>
        <span style="color: #007800;">RETVAL</span>=<span style="color: #007800;">$?</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span>
        <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$RETVAL</span> = <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #c20cb9; font-weight: bold;">touch</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>lock<span style="color: #000000; font-weight: bold;">/</span>subsys<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$prog</span>
        <span style="color: #000000; font-weight: bold;">;;</span>
    stop<span style="color: #7a0874; font-weight: bold;">&#41;</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;Shutting down <span style="color: #007800;">$prog</span>: &quot;</span>
        killproc <span style="color: #660033;">-d</span> <span style="color: #000000;">60</span> <span style="color: #007800;">$prog</span>
        <span style="color: #007800;">RETVAL</span>=<span style="color: #007800;">$?</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span>
        <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$RETVAL</span> = <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>lock<span style="color: #000000; font-weight: bold;">/</span>subsys<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$prog</span>
        <span style="color: #000000; font-weight: bold;">;;</span>
    status<span style="color: #7a0874; font-weight: bold;">&#41;</span>
        status <span style="color: #007800;">$prog</span>
        <span style="color: #000000; font-weight: bold;">;;</span>
    restart<span style="color: #7a0874; font-weight: bold;">&#41;</span>
        $<span style="color: #000000;">0</span> stop
        $<span style="color: #000000;">0</span> start
        <span style="color: #000000; font-weight: bold;">;;</span>
    <span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Usage: $0 {start|stop|restart|status}&quot;</span>
        <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">esac</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">0</span></pre></td></tr></table></div>

<p>make /etc/init.d/rsyncd executable, and register this service</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>3
4
5
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">chmod</span> +x <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>rsyncd 
<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>chkconfig <span style="color: #660033;">--add</span> rsyncd
<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>service rsyncd start</pre></td></tr></table></div>

<p><strong>Setup rsync client</strong></p>
<p>first, of course you must have rsync installed on client server</p>
<p>make rsync password file</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>etc
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> rsync
<span style="color: #7a0874; font-weight: bold;">cd</span> rsync
<span style="color: #c20cb9; font-weight: bold;">touch</span> rsync.pwd
<span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #000000;">600</span> rsync.pwd</pre></td></tr></table></div>

<p>vi /etc/rsync/rsync.pwd</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">user_1_password</pre></td></tr></table></div>

<p>execute this command to start synchronize file to server</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">rsync <span style="color: #660033;">-vrtLogp</span> <span style="color: #660033;">--progress</span> <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>directory<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>be<span style="color: #000000; font-weight: bold;">/</span>backup<span style="color: #000000; font-weight: bold;">/*</span> my_rsync_user_1<span style="color: #000000; font-weight: bold;">@</span><span style="color: #7a0874; font-weight: bold;">&#91;</span>SERVER_IP<span style="color: #7a0874; font-weight: bold;">&#93;</span>::profile_1 <span style="color: #660033;">--password-file</span>=<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>rsync<span style="color: #000000; font-weight: bold;">/</span>rsync.pwd</pre></td></tr></table></div>

<p>where [SERVER_IP] is rsync server IP</p>
<a rel="external nofollow" class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.fengcool.com%2F2009%2F07%2Frsync_server_and_client_backup_server_file%2F&amp;linkname=Rsync%20server%20and%20client%20%26%238211%3B%20backup%20your%20server%20files"><img src="http://www.fengcool.com/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share/Save/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://www.fengcool.com/2009/07/rsync_server_and_client_backup_server_file/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

