The records that rsync synchronizes

Source: Internet
Author: User
Tags auth chmod file copy file size file system file permissions iptables least privilege

Rsync:

Official website: http://rsync.samba.org/

Official documents: http://rsync.samba.org/documentation.html

Tea: The article has not finished, temporarily may not be able to enter your discernment. Please skip.

Note:

1. The permission setting for the password must be 600

First, Introduction:

Rsync is a data mirroring Backup tool under Unix-like systems, and--remote sync can be seen from the name of the software. Its characteristics are as follows:

Can be mirrored to save the entire directory tree and file system.

It is easy to maintain the original file permissions, time, soft and hard links and so on.

can be installed without special permissions.

Optimized flow, high efficiency of file transfer.

You can use RCP, ssh, and so on to transfer files, of course, through a direct socket connection.

Support for anonymous transmission, to facilitate the use of Web site mirror image.

Second, simple sequence process:

1, rsync service-side launch

2. Load configuration file

3, client connections, server-side authentication profiles, permissions, and so on, and then interactive files.

Third, the installation process:

1. Install rsync xinetd (managed rsync)

#yum-y Install rsync xinetd

2, xinetd to start when it starts

#vi/etc/xinetd.d/rsync

[Disable = no]

3, Firewall Policy

#vi/etc/sysconfig/iptables

[-A rh-firewall-1-input-p tcp-m TCP--dport 873-j ACCEPT]

#service iptables Restart

4, edit the configuration file

#vi/etc/rsyncd.conf

[

Max connections = 5

Log file =/var/log/rsync.log

UID = nobody

GID = Nobody

[web]

Path =/web/html

Read Only = yes

Hosts allow = 192.168.2.0/24

]

5. Set Boot up

#service xinetd Start

#chkconfig xinetd--level 3 on

#netstat-ant

:: 873

6, SELinux settings

#setenforce Permissive

#vim/etc/sysconfig/selinux

[Selinux=disabled]

7. Client Testing

#rsync--progress-av--delete rsync://192.168.2.88/web/web/backup/html/

Formal environment (permissions are self-matched)

For specific configuration options, refer to the rsync manual: #rsync--help

#vim/etc/rsyncd.conf

[

Max connections = 5

Log file =/var/log/rsync.log

Log pid =/var/log/rsync.pid

UID = Nobody (available file owner)

GID = Nobody (available file group)

Use chroot = no

[WWW]

Path =/web/www

Read Only = True

List = False

Hosts allow = 192.168.2.0/24

Hosts Deny = 0.0.0.0/32

Auth users = www

Secrets file =/etc/rsync.pass

[BBS]

Path =/web/bbs

Read Only = True

List = False

Hosts allow = 192.168.2.0/24

Hosts Deny = 0.0.0.0/32

Auth users = BBS

Secrets file =/etc/rsync.pass

[Blog]

Path =/web/blog

Read Only = True

List = False

Hosts allow = 192.168.2.0/24

Hosts Deny = 0.0.0.0/32

Auth users = Blog

Secrets file =/etc/rsync.pass

]

#vim/etc/rsync.pass

[

www:111111

bbs:222222

blog:333333

]

#chmod 600/etc/rsync.pass

The command format for rsync:

rsync [OPTION] ... src [src] ... [user@] Host:dest

rsync [OPTION] ... [user@] HOST:SRC DEST

rsync [OPTION] ... src [src] ... DEST

rsync [OPTION] ... [user@] HOST::SRC [DEST]

rsync [OPTION] ... src [src] ... [user@] HOST::D EST

rsync [OPTION] ... rsync://[user@]host[:P ort]/src [DEST]

Rsync has six different modes of operation:

Copy local files and start this mode of work when both SRC and des path information do not contain a single colon ":" delimiter.

Use a remote shell program (such as rsh, SSH) to copy the contents of the local machine to the remote machine. This mode is started when the DST path address contains a single colon ":" Separator.

This column more highlights: http://www.bianceng.cn/OS/Linux/

Use a remote shell program (such as rsh, SSH) to copy the contents of the remote machine to the local machine. This mode is started when the SRC address path contains a single colon ":" Separator.

Copy files to the local machine from a remote rsync server. This mode is started when the SRC path information contains the "::" delimiter.

Copy files from the local machine to the remote rsync server. This mode is started when the DST path information contains the "::" separator.

List of files for the remote machine. This is similar to rsync transmission, but simply omitting the local machine information in the command.

-V,--verbose verbose mode output

-Q,--quiet thin output mode

-C,--checksum Open the check switch to force the file transfer to verify

-A,--archive archive mode, which represents the transfer of files recursively and maintains all file attributes equal to-rlptgod

-R,--recursive the subdirectory in recursive mode

-R,--relative using relative path information

-B,--backup creates a backup, which means that the old file is renamed to ~filename for the same file name already exists for the purpose. You can use the--suffix option to specify different backup file prefixes.

--backup-dir store backup files (such as ~filename) in the directory.

-suffix=suffix defines the backup file prefix

-U,--update only updates, skipping all files that already exist in DST, and the file time is later than the file you want to back up. (Do not overwrite the updated file)

-L,--links retention soft link knot

-L,--copy-links to treat soft links like regular files

--copy-unsafe-links only copies links that point beyond the src Path directory tree

--safe-links ignores links to the SRC path tree

-H,--hard-links keep hard links

-P,--perms keep file permissions

-O,--owner keep file owner information

-G,--group keep file group information

-D,--devices maintain device file information

-T,--times keep file time information

-S,--sparse special handling of sparse files to save DST space

-N,--dry-run which files will be transmitted

-W,--whole-file copy files without 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 a shell program that replaces rsh

--RSYNC-PATH=PATH Specifies the path information for the rsync command on the remote server

-C,--cvs-exclude use the same method as CVs to automatically ignore files to exclude files that you do not want to transfer

--existing updates only those files that already exist in DST, not the newly created files

--delete Delete files that are not in the DST SRC

--delete-excluded also deletes the receiving end of files that are excluded by the option specified

--delete-after after transmission is over

--ignore-errors in time IO errors are also deleted

--max-delete=num Delete NUM files up to

--partial retains files that are not fully transmitted for some reason, to expedite subsequent transmissions

--force forcibly deletes a directory, even if it is not empty

--numeric-ids does not match the user and group IDs of numbers to user and group names

--timeout=time IP timeout time in seconds

-I,--ignore-times not skip those files that have the same time and length

--size-only when deciding whether to back up a file, just look at the file size without considering the file time

--modify-window=num the time stamp window that determines whether a file is in the same time, default is 0

-t--temp-dir=dir create temporary files in dir

--compare-dest=dir also compares files in DIR to determine whether a backup is required

-P equals to--partial

--progress Display backup process

-Z,--compress compression of backed-up files on transfer

--EXCLUDE=PATTERN Specifies to exclude file modes that do not require transfer

--INCLUDE=PATTERN Specifies the file mode that is not excluded and needs to be transferred

--exclude-from=file exclude files in the specified mode in file

--include-from=file does not exclude files that match the file-specified pattern

--version Print version Information

--address bound to a specific address

--CONFIG=FILE specifies a different profile and does not use the default rsyncd.conf file

--PORT=PORT Specifies the other rsync service ports

--blocking-io blocking IO for a remote shell

-stats gives the transfer status of some files

--progress transmission process in real time

--log-format=format Specify log file format

--password-file=file gets the password from file

--bwlimit=kbps limit I/O bandwidth, Kbytes per second

-H,--help display Help information

Client connections:

#vim/etc/rsync.www

[111111]

#vim/etc/rsync.bbs

[222222]

#vim/etc/rsync.blog

[333333]

To set Password file permissions:

#chmod 600/etc/rsync. {Www,bbs,blog}

Client Connection www module:

#rsync--progress-av--delete www@192.168.2.88::www/web/backup/www/--passwordfile=/etc/rsync.www

Client Connection BBS module:

#rsync--progress-av--delete bbs@192.168.2.88::bbs/web/backup/bbs/--password-file=/etc/rsync.bbs

Client Connection Blog module:

#rsync--progress-av--delete blog@192.168.2.88::blog/web/backup/blog/--password-file=/etc/rsync.blog

Client Push:

rsync--PROGRESS-AVR--delete/web/www/html/www@192.168.2.88::www--password-file=/etc/rsync.www

Note: There is/means to synchronize all documents in this directory after/web/www/html/html. Instead of synchronizing the HTML folder.

Task Schedule:

#crontab-E

[

*/1 * * * * rsync--progress-av--delete www@192.168.2.88::www/data/backup/www/--password-file=/etc/rsync.www

]

If you want to build a network source, or local source synchronization, to sync the latest files. I found a good source in the official website, the specific source address. There seems to be no support for rsync at home.

SOURCE list: http://www.centos.org/modules/tinycontent/index.php?id=30

#rsync--progress-av--delete linux.mirrors.es.net::centos/data/centos/

Tea tasting: For security, refer to the default security, which is the least privilege setting.

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.