I. Environment:
OS: SunOS
Compiler: GCC 4.2.4
Perl 5.8.7
Make 3.81
Ii. Required Software
Rsync-3.0.7.tar.gz
3. Install software
1, installation process: Tar xvzf rsync-3.0.7.tar.gz
CD rsync-3.0.7
./Configure -- prefix =/usr/local/rsync
(Note: For Unix machines, the default compiler is CC, and compilation fails. You need to set it to GCC:
Cc = GCC./configure -- prefix =/usr/local/rsync)
Make
Make install
Parameter description: -- prefix specifies the directory where Rsync is to be installed.
2. Rsync Configuration
/Etc/rsyncd. conf (it is not available by default and can be created manually)
# Global Options
Strict modes = yes # Check the permission of the password file
Port = 873 # default port 873
Log File =/var/log/rsyncd. log # log record file
PID file =/usr/local/rsync/rsyncd. pid # Where to write the ID of the running process
# Module options
[Test] # The Authentication Module name must be specified on the client.
Max connections = 5 # maximum number of client connections. The default value is 0 (no limit)
Uid = livedoorcn # specify the UID that the daemon should have when the module transfers files
Gid = livedoorcn # specify the GID that the daemon should have when the module transfers files
Path =/home/rsync_test # directory for backup
Ignore errors # ignore unrelated Io errors
Read Only = No # No client can upload files, Yes read-only
Write only = No # No client can download files, yes cannot download
Hosts allow = * # allow any host connection
Hosts deny = 10.5.3.77 # disable specified host connection
Auth users = livedoorcn # The authenticated user name. If this line is not displayed, it indicates that it is anonymous.
Secrets file =/usr/local/rsync/rsyncd. scrt # specify the location of the authentication Password File
3. Generate the rsync Password File
Generate a password file/usr/local/rsync/rsyncd. scrt on the server.
VI rsyncd. scrt
--------- Content ----------
Livedoorcn :******
---------- End -------------
Note: The permission for the password file is set by the parameters in rsyncd. conf.
Strict modes = yes/no
4. Rsync startup
Rsycn has many startup methods. Here we will introduce the following:
●. Daemon mode:
/Usr/local/rsync/bin/rsync -- daemon
●. Inetd method:
Add the following to/etc/services:
Rsync 873/tcp
Then add the following to/etc/inetd. conf:
Rsync stream tcp Nowait root/usr/local/bin/rsync rsyncd -- daemon
●. Add RC. Local (FreeBSD)
Edit/etc/rc. d/rc. Local and add:
/Usr/local/bin/rsync -- daemon
5. Verify that the startup is successful.
PS-Aux | grep rsync
Root 59120 0.0 0.2 1460 972 ?? SS pm. 00/usr/local/rsync/bin/rsync-daemon
Netstat-an | grep 873
Tcp4 0 0 *. 873 *. * listen
6. Install the rsync client (here the server and client are the same machine)
Installation environment: FreeBSD 6.0-release
Software: rsync-3.0.7.tar.gz
Installation path:/usr/local/rsync
: Http://rsync.samba.org/
Installation Process: Tar xvzf rsync-3.0.7.tar.gz
CD rsync-3.0.7
./Configure -- prefix =/usr/local/rsync
Make
Make install
Parameter description: -- prefix specifies the directory where Rsync is to be installed.
Now, the installation process is complete.
7. instance demonstration
CD/usr/local/rsync/bin
Download files
./Rsync-vzrtopg -- Progress -- delete colin@10.5.3.98: Test/tmp/rsync
Upload files
./Rsync-vzrtopg -- Progress -- delete/tmp/rsync colin@10.5.3.98: Test
8. Rsync synchronization Parameters
-In vzrtopg, V is verbose, z is compression, R is recursive, and topg is a parameter that maintains the original file attributes, such as owner and time.
-- Progress indicates that the detailed progress is displayed.
-- Delete: if the server deletes the file, the client also deletes the file.
Colin in colin@10.5.3.98 is the user name in the specified password file
: Test refers to the module name defined in rsyncd. conf.
/Tmp/rsync refers to the local directory to be backed up