Application and practice of rsync

Source: Internet
Author: User
Tags rsync

Background

Advantages of RYSNC

1 can be used as differential transmission to save bandwidth and transfer time

2 can run data Backup center as a service (running on port 873)

3 as a service, configuration file changes under the Rsyncd.conf module do not need to be restarted-daemon



[Options for Rsync]

-A

-V

-Z transfer process to compress, if the pass is a file, picture compression before and after the file size has a big difference can be added!

-P

-H--hard-links

--exclude=pattern Exclude Files Matching PATTERN

Common 1

Rsync-avz


Common 2

Rsync-zvh

The-h parameter is required because the-a option does not retain a hard connection

Common 3

RSYNC-AVH --delete-after--exclude= '. ~tmp~ '

--delete-after

By default, Rsync is the first to clean up the destination files before starting data synchronization, and if you use this option, Rsync will synchronize the data before deleting the files that need to be cleaned.


Reference:

http://roclinux.cn/?p=2643



case One: host1----> Host2, two hosts do not know the root password, so the SCP is not convenient, you can sudo to root but cannot change root.  Now you can use rsync between two hosts! If you have a timed task copy rsync is the best option.


Host2 as a service run, the simplest/etc/rsyncd.conf configuration file is written

[Email protected]_server src]# cat/etc/rsyncd.conf

[Src]path=/usr/local/srcread only = Nouid = root GID = root


Run rsync

Rsync--daemon




host1 transfer files under local/usr/local/src to Host2 src module (i.e. under/USR/LOCAL/SRC)

Rsync-avz/usr/local/src/php-5.3.27.tar.gz 192.168.100.20::SRC



Attention:

1 This transfer process is not required for any password

2 UID GID is specified as root because writing under/USR/LOCAL/SRC requires root permission.

3 Read Only =no is because the default is read-only





case two: as with the case, just to authenticate the password (note that the virtual account (Rsync account authentication), and the system account is not the same) and some of the default configuration parameters to the detailed write and write in the global, non-module below


Cat/etc/rsyncd.conf

Port = 873uid =rootgid =rootuser chroot = Nomax connections = 20timeout = 600pid File =/var/run/rsyncd.pidlock File =/va R/run/rsyncd.locklog file =/var/run/rsyncd.log[src]path=/usr/local/srcignore Errorsread only = Nouid = root GID = Rootaut H users= rootsecrets file =/etc/rsyncd.secrets



Write Rsync's account password file

cat/etc/rsyncd.secretsroot:123456


Change permissions (permissions must be 600)

chmod 600/etc/rsyncd.secrets



Transferring files

[Email protected] src]# rsync-avz/usr/local/src/libmcrypt-2.5.8 [email protected]::src

Password:


Or use the specified password file instead of the interactive file transfer

First edit a password file ( permissions must be 600 other people unreadable, to take effect )

Cat/etc/rsyncd.password

123456

chmod 600/etc/rsyncd.password

Chitian Transfer to Host2

Rsync-avz--password-file=/etc/rsyncd.password/usr/local/src/libmcrypt-2.5.8 [Email protected]::src





This article is from the "Tridewah operation and maintenance work Road" blog, please be sure to keep this source http://cuidehua.blog.51cto.com/5449828/1786217

Application and practice of rsync

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.