rsync and rsync background mode [Reserved]

Reprinted from this link: https://www.cnblogs.com/hanxiaohui/p/8675409.html

Only for self-study.

 

 

rsync and rsync background mode

 

Note (There rsync soft-wired synchronization, -L can be a soft link in when ordinary file synchronization.-L-sync to sync only soft link directory or file a soft link points) 

rsync command Detailed

Copy the code
the rsync   
-a archive mode, transfer files recursively expressed, and maintaining all the properties equivalent to -rlptgoD, -a option with a rear --no-OPTION This means closed in one -rlptgdoD -a --no e.g. -l equivalent -rptgoD -R & lt for recursive directory processing mode, mainly for the directory, the directory must be added the transmission -R & lt -v print out some of the information, such as speed, number of files. -l retained even soft chain -L treatment to treat soft links as a regular file, and if src (source machine) in soft link file, just add this option will soft connection point to the target file copied to dst (target ) -p to keep file permissions -o to keep the file owner information -g keep the file is a set of information -D holding device file information -t time to keep file information --delete delete those files in src dst not --exclude = PATTERN exclude specified file transfer is not required, followed by an equal sign with the file name, can be a wildcard character mode (such as .txt *)
  the pATTERN path is a relative path to get to be synchronized as (rsync -avPz --exclude = zabbix / opt / sh 10.8. 64.99 :: backup / tmp / # is excluded / opt / SH / zabbix) --progress or -P can see the status of the synchronization process during synchronization, the number of files you want to sync statistics such as file transfer speed sync and many more. . . --bwlimit = 10 (transmission speed limit) -u This option will put together than DST SRC also ruled out a new file, not overwrite process will -z compression and transmission of compression, we do not perceive. Files to the target machine on what we see is the same. (Commonly used in the work of several -a -v --delete --exclude, please memorize them)
Copy the code

rsync several writing:

Copy the code
ssh rsync synchronization tunneled: the latter is the destination address directory # 
    Example 1: rsync -avPz 192.168.183.109:/tmp/1.txt / tmp / pull remote to local 
    Example 2: rsync -avPz /tmp/1.txt 192.168 .183.109: / tmp / push the machine to a remote 
    Example 3: case rsync -avPz -e "ssh -p 10022" /tmp/1.txt 192.168.183.109:/tmp/ push the unit 22 to the remote port is not 
synchronizing with rsync a daemon 
    Example 4: Free not require cryptography ssh password 
    rsync -auvPz --bwlimit = 10 (transmission speed restrictions) net-snmp-5.7.3.tar.gz [email protected] :: test --password-file = / home / hanxiaohui / .rsync.password 
    Example 5: query rsyncd available modules (list parameter, yes displayed, no does not display) 
    the rsync --port -list :: 873 192.168.186.118
Copy the code

Detailed rsync daemon configuration file

Copy the code
port = 873 which is the default port, use other ports to change the 
log file = / var / log / rsync.log specified log file 
pid file = / var / run / rsyncd.pid specified pid, start stop support operations such as process management 
# rsyncd designated start address = 192.168.0.10 IP services, if your machine has a plurality of IP, which can specify a start rsyncd service, the default is to start on the whole IP 
[Test] specify a module name, a custom 
path = / root / rsync data storage path (will be reported @ERROR path does not exist: chroot failed the) 
use chroot = to true to true | false default is true, meaning that in the first before transferring files to the chroot path parameters under the specified directory. The reason for this is to achieve additional security, but the drawback is the need to root privileges, and can not back up files to a directory outside of the symbolic link points to. Chroot default value is true, then if there is a flexible connection among the data file you recommend arranged to false. (To be authenticated) 
max = Connections. 4 specifies the maximum number of connections, i.e. no default limit is 0. 
read only = no true if the module can not be uploaded to the specified path. 
list = true when the user specifies a query module is available on the server, whether the module is listed, lists set true, to false hidden 
uid = root 
when gid = root uid / gid designated transmission file to which users / groups transmission identity
auth users = user name to be used when specifying transmission test
secrets file = / etc / rsyncd.passwd specified password file, this parameter together with the above parameter is not used if not specified password authentication, note that the password must be a file permissions 600 (with respect to the user to start rsync) 
the hosts the allow = 192.168. 183.109 192.168.55.0/24 is allowed to specify a host connected to the module, segment, or may be Ip, if a plurality is separated by spaces. 
Configuration file into two parts: a global module may have a plurality of modules 
overall: port, log file, pid file , address 
fact, some parameters such modules use chroot, max connetcions, uid, gid, auth users, secrets file, hosts It can be configured to allow global.
Copy the code

rsync daemon start

rsync --daemon --config=/etc/rsyncd.conf

rsync daemon Examples 1 (no password)

Copy the code
[@ host1 the root 111] /etc/rsyncd.conf CAT # 
# Port = 873 
log File = / var / log / rsync.log 
PID File = / var / RUN / rsyncd.pid 
UID = the root 
GID = the root 
[Test] 
path = / the root / Test 
use CHROOT = NO 
max = 50 Connections 
Read only NO = 
List = to true 
the ignore errors 
timeout = 600 
the hosts the allow = 192.168.55.0 / 24 


start 
rsync --daemon --config = / etc / rsyncd.conf 

client synchronization
rsync -avPz / tmp / abc 192.168.55.51::test/ # abc directory to be synchronized to the server module test

Example 2:
UID = Git Deploy
the rsync --no -avPz --no-O-G / Data / Media / * 47.100.217.13::data/ # this synchronization mode, users and groups are the target file deploy
Copy the code

Examples 1 rsync daemon (password)

Copy the code
= 873 Port # 
log File = / var / log / rsync.log 
PID File = / var / RUN / rsyncd.pid 
UID = the root 
GID = the root 
# address = 192.168.0.10 
[Test] 
path = / the root / the rsync # 
use CHROOT to true = 
max Connections 50 = 
Read only NO = 
List = to true 
the ignore errors 
timeout = 600 
the auth Users = Test 
Secrets = File / etc / rsyncd.passwd 
the hosts the allow = 192.168.183.0 / 24 
2. edit secrets file, save 600 to impart authority, if the authority does not complete the synchronization (relative to the start rsync user) 
CAT /etc/rsyncd.passwd the Test: test123 
chmod 600 / etc / rsyncd.passwd change permissions 

to start rsync 
rsync --daemon --config = / etc / rsyncd.conf start the service  
can be launched to look at the log files, and start to see whether the port
cat /var/log/rsync.log netstat -lnp | grep 873 
If you wish to start, please command 
#rsync --daemon --config = / etc / rsyncd.conf written to /etc/rc.d/rc. local file rsyncd.conf modify the configuration file does not need to restart the service 

one case: rsync -avLpz [email protected] :: test / test / ./test1/ remote to local pull 
Example 2: rsync -avL ./test2/ test @ 192.168.183.118 :: test / test / push the machine to a remote 
Example 3: custom port 
rsync -avL --port 8730 ./test2/ [email protected] :: test / test / push the machine to a remote 
Example 4 : free lost password 
1.vim / etc / pass code to join the test test123 
2. password to modify the 600 chmod / etc / Pass 
3. specified at the time about the password file synchronization 
rsync -avL ./test2/ [email protected] :: test / test / --password-file = / etc / pass # the password file must be an owner with the same executor
Copy the code

 

 
 

Note (There rsync soft-wired synchronization, -L can be a soft link in when ordinary file synchronization.-L-sync to sync only soft link directory or file a soft link points) 

rsync command Detailed

Copy the code
the rsync   
-a archive mode, transfer files recursively expressed, and maintaining all the properties equivalent to -rlptgoD, -a option with a rear --no-OPTION This means closed in one -rlptgdoD -a --no e.g. -l equivalent -rptgoD -R & lt for recursive directory processing mode, mainly for the directory, the directory must be added the transmission -R & lt -v print out some of the information, such as speed, number of files. -l retained even soft chain -L treatment to treat soft links as a regular file, and if src (source machine) in soft link file, just add this option will soft connection point to the target file copied to dst (target ) -p to keep file permissions -o to keep the file owner information -g keep the file is a set of information -D holding device file information -t time to keep file information --delete delete those files in src dst not --exclude = PATTERN exclude specified file transfer is not required, followed by an equal sign with the file name, can be a wildcard character mode (such as .txt *)
  the pATTERN path is a relative path to get to be synchronized as (rsync -avPz --exclude = zabbix / opt / sh 10.8. 64.99 :: backup / tmp / # is excluded / opt / SH / zabbix) --progress or -P can see the status of the synchronization process during synchronization, the number of files you want to sync statistics such as file transfer speed sync and many more. . . --bwlimit = 10 (transmission speed limit) -u This option will put together than DST SRC also ruled out a new file, not overwrite process will -z compression and transmission of compression, we do not perceive. Files to the target machine on what we see is the same. (Commonly used in the work of several -a -v --delete --exclude, please memorize them)
Copy the code

rsync several writing:

Copy the code
ssh rsync synchronization tunneled: the latter is the destination address directory # 
    Example 1: rsync -avPz 192.168.183.109:/tmp/1.txt / tmp / pull remote to local 
    Example 2: rsync -avPz /tmp/1.txt 192.168 .183.109: / tmp / push the machine to a remote 
    Example 3: case rsync -avPz -e "ssh -p 10022" /tmp/1.txt 192.168.183.109:/tmp/ push the unit 22 to the remote port is not 
synchronizing with rsync a daemon 
    Example 4: Free not require cryptography ssh password 
    rsync -auvPz --bwlimit = 10 (transmission speed restrictions) net-snmp-5.7.3.tar.gz [email protected] :: test --password-file = / home / hanxiaohui / .rsync.password 
    Example 5: query rsyncd available modules (list parameter, yes displayed, no does not display) 
    the rsync --port -list :: 873 192.168.186.118
Copy the code

Detailed rsync daemon configuration file

Copy the code
port = 873 which is the default port, use other ports to change the 
log file = / var / log / rsync.log specified log file 
pid file = / var / run / rsyncd.pid specified pid, start stop support operations such as process management 
# rsyncd designated start address = 192.168.0.10 IP services, if your machine has a plurality of IP, which can specify a start rsyncd service, the default is to start on the whole IP 
[Test] specify a module name, a custom 
path = / root / rsync data storage path (will be reported @ERROR path does not exist: chroot failed the) 
use chroot = to true to true | false default is true, meaning that in the first before transferring files to the chroot path parameters under the specified directory. The reason for this is to achieve additional security, but the drawback is the need to root privileges, and can not back up files to a directory outside of the symbolic link points to. Chroot default value is true, then if there is a flexible connection among the data file you recommend arranged to false. (To be authenticated) 
max = Connections. 4 specifies the maximum number of connections, i.e. no default limit is 0. 
read only = no true if the module can not be uploaded to the specified path. 
list = true when the user specifies a query module is available on the server, whether the module is listed, lists set true, to false hidden 
uid = root 
when gid = root uid / gid designated transmission file to which users / groups identity transport 
auth users = user name to be used when specifying transmission test
secrets file = / etc / rsyncd.passwd specified password file, this parameter together with the above parameter is not used if not specified password authentication, note that the password must be a file permissions 600 (with respect to the user to start rsync) 
the hosts the allow = 192.168. 183.109 192.168.55.0/24 is allowed to specify a host connected to the module, segment, or may be Ip, if a plurality is separated by spaces. 
Configuration file into two parts: a global module may have a plurality of modules 
overall: port, log file, pid file , address 
fact, some parameters such modules use chroot, max connetcions, uid, gid, auth users, secrets file, hosts It can be configured to allow global.
Copy the code

rsync daemon start

rsync --daemon --config=/etc/rsyncd.conf

rsync daemon Examples 1 (no password)

Copy the code
[@ host1 the root 111] /etc/rsyncd.conf CAT # 
# Port = 873 
log File = / var / log / rsync.log 
PID File = / var / RUN / rsyncd.pid 
UID = the root 
GID = the root 
[Test] 
path = / the root / Test 
use CHROOT = NO 
max = 50 Connections 
Read only NO = 
List = to true 
the ignore errors 
timeout = 600 
the hosts the allow = 192.168.55.0 / 24 


start 
rsync --daemon --config = / etc / rsyncd.conf 

client synchronization
rsync -avPz / tmp / abc 192.168.55.51::test/ # abc directory to be synchronized to the server module test

Example 2:
UID = Git Deploy
the rsync --no -avPz --no-O-G / Data / Media / * 47.100.217.13::data/ # this synchronization mode, users and groups are the target file deploy
Copy the code

Examples 1 rsync daemon (password)

Copy the code
= 873 Port # 
log File = / var / log / rsync.log 
PID File = / var / RUN / rsyncd.pid 
UID = the root 
GID = the root 
# address = 192.168.0.10 
[Test] 
path = / the root / the rsync # 
use CHROOT to true = 
max Connections 50 = 
Read only NO = 
List = to true 
the ignore errors 
timeout = 600 
the auth Users = Test 
Secrets = File / etc / rsyncd.passwd 
the hosts the allow = 192.168.183.0 / 24 
2. edit secrets file, save 600 to impart authority, if the authority does not complete the synchronization (relative to the start rsync user) 
CAT /etc/rsyncd.passwd the Test: test123 
chmod 600 / etc / rsyncd.passwd change permissions 

to start rsync 
rsync --daemon --config = / etc / rsyncd.conf start the service  
can be launched to look at the log files, and start to see whether the port
cat /var/log/rsync.log netstat -lnp | grep 873
If you wish to start, please command 
#rsync --daemon --config = / etc / rsyncd.conf written to the /etc/rc.d/rc.local file rsyncd.conf modify the configuration file without restarting the service 

Example 1 : rsync -avLpz [email protected] :: test / test / ./test1/ remote to local pull 
Example 2: rsync -avL ./test2/ [email protected] :: test / test / pushing the unit to the remote 
Example 3: custom port 
rsync -avL --port 8730 ./test2/ [email protected] :: test / test / push the machine to a remote 
Example 4: Free input password 
1.vim / etc / pass password added test test123 
2. Change password permission 600 chmod / etc / Pass 
3. specified at the time about the password file synchronization 
rsync -avL ./test2/ [email protected] :: test / test / --password-file = / etc / pass # the password file must be the executor with the same owner
Copy the code

 

Guess you like

Origin www.cnblogs.com/fengxingzhe/p/11220414.html