Rsync synchronization tool installation documentation, rsync synchronization documentation
(1) download the Rsync source code for Installation
(2) 1' cd rsync
2'./configure -- prefix =/usr/local/rsync
3 'make
4 'make install (permissions may be required, plus sudo)
(3) Rsync command synchronization Parameter options (learn more)
Rsync [OPTION...] SRC... DEST
Description of common Parameter options:
-V, -- verbose detailed mode output, transmission progress, and other information
-Z, -- compress compression during transmission to improve transmission efficiency. -- compress-level = NUM can be compressed by level.
-R, -- recursive uses recursive mode for sub-directories, that is, all directories under the directory are also transmitted, note that it is in lower case r
-T, -- times preserve the file time information
-O, -- owner keeps file owner information
-P, -- perms to keep File Permissions
-G, -- group: Keep file group information
-P, -- progress displays the synchronization process and the progress during transmission.
-A, -- archive mode, indicating that the file is transmitted recursively and all file attributes are kept, equal to-rtopgDl
-D, -- devices: Keep Device File Information
-L, -- links retains soft links
-E, -- rsh = the channel protocol used by COMMAND, specifying the shell program that replaces rsh. Example: ssh
-- Exclude = PATTERN specifies to exclude file modes that do not need to be transmitted
The above are commonly used parameters: more parameters please manually man rsync or view the address: http://www.samba.org/ftp/rsync/rsync.html
Vza is equivalent to vzrtopgDl
Note:
Rsync-avz/opt // mnt # Add/to synchronize only contents in the directory
Rsync-avz/opt/mnt # without adding/, the contents in the Directory and the contents in the directory will be synchronized together
(4) server configuration: cd/usr/local/rsync
(5) echo "rsync-pwd">/usr/local/rsync. passwd (if you need the permission, change it to sudo su root and run the command ).
(6) chmod 600 rsync. passwd
(7) Add the following content to vi/usr/local/rsync. conf:
Uid = root
Gid = root
Use chroot = no
Max connections = 10000
Strict modes = yes
Address = 192.168.11.73 (the IP address of the server to be synchronized from the server address)
Pid file =/var/run/rsyncd. pid
Lock file =/var/run/rsync. lock
Log file =/var/log/rsyncd. log
[Public]
Path =/home/public (directory to be synchronized)
Comment = web file
Ignore errors
Read only = no
Write only = no
Hosts allow = *
List = false
Uid = root
Gid = root
Auth users = root, HeQiang (this is your computer user name)
Secrets file =/usr/local/rsync. passwd
(7) Start the rsync server: before running, make sure that your rsync has enabled ps-ef | grep rsync.
/Usr/local/rsync/bin/rsync -- daemon -- config =/usr/local/rsync. conf
(8) sudo su root
(9) rsync-avz HeQiang@192.168.11.73:/home/public // test/(HeQiang is the server computer user name followed by the server computer ip: the directory to be copied is followed by the path to be copied)
(10) The system prompts that a password is required. Enter the password of the opposite server!
(11) Synchronous push: rsync-avz/test/root@192.168.11.207:/home/public/
(12) rsync-avz -- delete root@192.168.11.207:/home/public/test/-- delete option, indicates that the data on the client must be exactly the same as that on the server, delete a file that does not exist on the server in the linuxsirhome directory. The ultimate goal is to make the data in the linuxsirhome directory completely consistent with that on the server; Be careful when using it; it is best not to treat the directory with important data as a local update directory, otherwise, all your data will be deleted;
(13) -- password-file =/etc/rsyncd. secrets
(14) rsync-avz -- password-file =/etc/rsync. password root@192.168.11.207:/home/public // test/
Password-free copy method: (using ssh Without Password copy)
(15) rsync-avz-e ssh root@192.168.11.207:/home/public // test/
Password-free Login
(16) ssh-keygen-t dsa (always enter)
(17) cd. ssh/
(18) scp id_dsa.pub root@192.168.11.207 :~ /Id_dsa_hostname.pub (hostname is your computer name)
(19) ssh root@192.168.11.207
(20) cat id_dsa_hostname.pub>. ssh/authorized_keys
Use rsync for linux Data Synchronization
Password file must not be other-accessible
That is to say, the permission settings for the rsyncd. scrt file are incorrect and cannot be accessed by other users. You can try chmod 600 rsyncd. scrt.
You are a newbie, And you can copy others' programs if you don't know anything. I think you should at least understand the usage of rsync and the basic principles of linux to do this.
In linux, how does one determine whether a single or a file is successfully synchronized when rsync is used to synchronize files?
This problem can be solved. You only need to add a command after your command line.
# Rsync... | echo! $
What is the meaning of the command? That is to say, if the previous command fails, the echo will be executed! $ Command, and! $ Variable indicates the parameter followed by the execution of the previous command. That is to say, if an error occurs when the rsync command synchronizes a file, the file name will be! $ Is recorded, so I think using this command we can know that the file encountered a problem when executing the rsync command. The command was successfully tested by myself. However, because my rsync didn't fail, I modified | to & for testing. The principle is the same.
I don't know if this is what LZ wants?