Linux rsync Service

Source: Internet
Author: User
Tags file copy rsync

1, Rsync Introduction
Rsync is an open source, fast, versatile and excellent tool for full-scale and incremental simultaneous backup of local or remote data, and rsync software works on nunix/linux/windows multiple operating systems.
Official website: http://www.samba.org/ftp/rsync/rsync.html
Rsync English is all called remote rynchronization.
Features of the Rsyn:
1) Support copying special files such as connection files, devices, etc.
2) can have excluded the specified file or directory synchronization to the function, the equivalent of packaging command tar exclusion function.
3) can be done to maintain the original file or directory permissions, time, soft connection, owner, group and all the attributes are not changed
4) can achieve incremental synchronization, that is, only synchronize the changed data
5) can use RCP,RSH,SSH and other ways to coordinate the transfer of files (rsync itself does not encrypt data)
6) file or data can be transferred via the socket process (server side and client)
7) Support the process mode transfer of anonymous or authentication (no system users), it can make the data backup and mirroring conveniently and safely.

Rsync in the way:
1) Local synchronization
rsync option Source Target
rsync option Srcoue dest
Equivalent to local CP command
Local:rsync [OPTION ...] Src... [DEST]

Access via remote shell:
Pull:rsync [OPTION ...] [[email protected]] Host:src ... [DEST]
Push:rsync [OPTION ...] Src... [[email protected]] Host:dest

Access via rsync daemon:
Pull:rsync [OPTION ...] [[email protected]] Host::src ... [DEST]
rsync [OPTION ...] rsync://[[email protected]]host[:P ort]/src ... [DEST]
Push:rsync [OPTION ...] Src... [[email protected]] HOST::D EST

2. Rsync Configuration
Yum Install-y rsync
wget http://pkgs.repoforge.org/rsync/rsync-3.0.9-2.el6.rfx.x86_64.rpm
1) configuration file
#服务端配置参数说明:
#uid = Rsync User
#gid = Rsync user Group
#port = 873 Specify port number
#use chroot = no or False
#list = no do not allow column list
#max connections = 200 Maximum number of connections
#hosts Allow = * Allows the network segment to be synchronized
#timeout = 300 Overrides the client-specified IP timeout period
#log file =/var/log/rsyncd.log where the log file is stored
#pid file =/var/run/rsyncd.pid pid file storage location
#lock file = location of/var/run/rsync.lock lock files
#motd file = message files when you specify a connection
#[test] Here is the name of the authentication module, which, like samba syntax, is the name published externally.
#path =/test/Here is the directory that participates in synchronization
#ignore errors can ignore some unrelated IO errors
#read only = False to allow readable writable
#hosts allow = 192.168.233.0/24 The address allowed to access
#host deny = 0.0.0.0/32 address not allowed to be accessed
#transfer logging = yes transfer log
#secrets file =/etc/rsync.password password files store address


Reference Official Document: Https://www.samba.org/ftp/rsync/rsyncd.conf.html
Rpm-qa rsync
Rsync-3.0.6-12.el6.x86_64

Vim/etc/rsyncd.conf
#rsync. config file
UID = rsync
GID = rsync
Use chroot = no
Max connections = 200
Hosts allow = *
Timeout = 300
Log file =/var/log/rsyncd.log
PID file =/var/run/rsyncd.pid
Lock file =/var/run/rsync.lock
# Module Definitions
[Test]
Path =/test/
Ignore errors
Read Only = False
Hosts allow = 192.168.233.0/24
Host Deny = 0.0.0.0/32
Transfer logging = yes
Secrets file =/etc/rsync.password
#rsync. conf---------End

2) Create backup directory, user, password file and specify permissions
Mkdir/test
Chown-r rsync.rsync/test/
Useradd-s/sbin/nologin-m rsync
echo "Rsyncback:123.com" >/etc/rsync.password
chmod 600/etc/rsync.password

3) Start Rsyn service
/usr/bin/rsync--daemon
Netstat-lntup|grep 873
TCP 0 0 0.0.0.0:873 0.0.0.0:* LISTEN 5490/rsync
TCP 0 0::: 873:::* LISTEN 5490/rsync
Ps-ef |grep rsync|grep-v grep
Root 5490 1 0 16:09? 00:00:00/usr/bin/rsync--daemon
1) Configure the startup script to put rsync service family to boot from.


3. Rsync Client Configuration
Rpm-qa rsync
Rsync-3.0.6-12.el6.x86_64
echo "123.com" >/etc/rsync.password
chmod 600/etc/rsync.password

1) Client access mode
Upload data:
rsync [OPTION ...] Src... [[email protected]] HOST::D EST
rsync-zvap/mnt/[Email protected]::test--password-file=/etc/rsync.password
rsync [OPTION ...] SRC ... rsync://[[email protected]]host[:P ort]/dest
Rsync-zvap/usr/src/kernels/rsync://[email protected]:873/test--password-file=/etc/rsync.password

Download data:
rsync [OPTION ...] [[email protected]] Host::src ... [DEST]
RSYNC-AVZP [email protected]::test ~/--password-file=/etc/rsync.password

rsync [OPTION ...] rsync://[[email protected]]host[:P ort]/src ... [DEST]
Rsync-avzp rsync://[email protected]:873/test ~/--password-file=/etc/rsync.password

#参数说明:
#-v,--verbose verbose mode output
#-q,--quiet thin output mode
#-c,--checksum turn on the check switch to force a checksum on the file transfer
#-a,--archive archive mode, which means to transfer files recursively and keep all file attributes equal to-rlptgod
#-r,--recursive the subdirectory is processed in recursive mode
#-r,--relative using relative path information
#-b,--backup Create a backup, that is, for the purpose already exists with the same file name, the old file is renamed to ~filename. You can use the--suffix option to specify a different backup file prefix.
#--backup-dir store backup files (such as ~filename) in the directory.
#-suffix=suffix Defining backup File prefixes
#-u,--update just updates, which is to skip all the files that already exist in DST, and the file time is later than the file to be backed up. (Does not overwrite the updated file)
#-l,--links keep soft link knot
#-l,--copy-links to treat soft links like regular files
#--copy-unsafe-links only copies links to links outside the SRC Path directory tree
#--safe-links ignoring links to the SRC Path directory tree
#-h,--hard-links reserved Hard links
#-p,--perms Keep file permissions
#-o,--owner keep file owner information
#-g,--group keep file group information
#-d,--devices keep device file information
#-t,--times keep file time information
#-s,--sparse Special processing of sparse files to save DST space
#-n,--dry-run Reality which files will be transmitted
#-w,--whole-file Copy file, no incremental detection
#-x,--one-file-system do not cross file system boundaries
#-b, the block size used by the--block-size=size test algorithm is 700 bytes by default
#-e,--rsh=command specifies the shell program to replace Rsh
#--rsync-path=path Specify the path information for the rsync command on the remote server
#-c,--cvs-exclude uses the same method as CVs to automatically ignore files to exclude files that you do not want to transfer
#--existing only updates those files that already exist in DST without backing up those newly created files
#--delete Delete those files that are not in the DST SRC
#--delete-excluded also deletes those files that are excluded by the option specified by the Receive side
#--delete-after transfer ends after removal
#--ignore-errors Timely IO errors are also deleted
#--max-delete=num deleting NUM files up to a maximum
#--partial retains files that are not fully transmitted for any reason, to expedite subsequent transmissions
#--force forcibly delete a directory, even if it is not empty
#--numeric-ids does not match the user and group ID of a number to a user name and group name
#--timeout=time IP time-out, in seconds
#-i,--ignore-times don't skip files that have the same time and length
#--size-only when deciding whether to back up a file, just look at the file size regardless of file time
#--modify-window=num determines whether the file is time-stamped with the time Stamp window, which defaults to 0
#-t--temp-dir=dir Creating temporary files in Dir
#--compare-dest=dir also compares the files in DIR to determine if a backup is required
#-p equivalent to--partial
#--progress Show Backup process
#-z,--compress compress the backed-up files on transfer
#--exclude=pattern specify to exclude file modes that do not need to be transferred
#--include=pattern specifies file modes that need to be transferred without exclusion
#--exclude-from=file exclude files in the specified schema in file
#--include-from=file does not exclude files that specify pattern matching
#--version Print version Information
#--address binding to a specific address
#--config=file specify a different configuration file, do not use the default rsyncd.conf file
#--port=port Specify a different rsync service port
#--blocking-io using blocking IO for remote shells
#-stats gives the transfer status of some files
#--progress in the transmission of the real-time transmission process
#--log-format=format specifying the log file format
#--password-file=file get the password from file
#--bwlimit=kbps limit I/O bandwidth, Kbytes per second
#-h,--HELP Display Help information
4. Parameter examples
Client exclusion methods:
1) Exclude individual files:--exclude
RSYNC-AVZP ~/--exclude=a [email protected]::test--password-file=/etc/rsync.password
2) Exclude multiple files:--exclude
Rsync-avzp ~/--exclude={a,b,c} [email protected]::test--password-file=/etc/rsync.password
3) Write the file that you want to exclude, and then specify the file:--exclude-from
rsync-avzp/python/aa/--exclude-from=/root/paichu [Email protected]::test--password-file=/etc/rsync.password

4) server-side exclusions:
Vim/etc/rsyncd.conf
[Test]
exclude = a b c d

5) No difference synchronization:
Upload the data, the client does not, the server will be deleted, keep in sync.
RSYNC-AVZP--delete/python/aa/[Email protected]::test--password-file=/etc/rsync.password
Downloading data will remove data from the client that is not available on the server.
RSYNC-AVZP--delete [Email protected]::test/python/aa/--password-file=/etc/rsync.password

Linux rsync Service

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.