Linux Remote Data Synchronization tool rsync (1), linuxrsync

Source: Internet
Author: User
Tags rsync

Linux Remote Data Synchronization tool rsync (1), linuxrsync

Rsync is a data backup tool rsync (remote sync) in linux)

Features: local data synchronization (similar to cp, but different from remote scp), it will first determine the differences between existing data and remote data, different parts are overwritten.

Rsync format

1. rysnc (Command Format) format (you need to enter the remote root password)

Note: When the rsync command is used between two machines to synchronize files, it is used together with ssh. ssh-keygen-t rsa can be used to regenerate a pair of keys. Public Key and private key.

If you want to synchronize the file of host A to host B, you can use ssh-keygen-t rsa on host A to regenerate A pair of Public Key: id_rsa.pub on host, the private key id_rsa is on the remote host B.

If the private key id_rsa of host A and id_rsa of remote host B are not generated. When you enter the password, the system prompts "Server refused our key"
Server refused our key"

Solution: You can use ssh-keygen-t rsa to regenerate a pair of keys.
Rsync [OPTION]... src dest (Local to local)
Rsync [OPTION]... SRC [USER @] HOST: DEST (local remote)
Rsync [OPTION]... [USER @] HOST: src dest (remote to local)
Rsync [OPTION]... [USER @] HOST: src dest (remote to local)
Rsync [OPTION]... SRC [USER @] HOST: DEST (local remote)

-A archive mode: Transfers files recursively and maintains all attributes, which is equivalent to-rlptgoD, -The end of OPTION a can be followed by a -- no-OPTION which indicates to disable-rlptgoD. For example,-a -- no-l is equivalent to-rptgoD.

-R processes subdirectories in recursive mode, mainly for directories. If you upload a file separately, you do not need to add-r, but you must add the-r option to the directory.

-V prints some information, such as the speed and number of files.

-L retain soft links

-L process soft links like regular files. If a soft connection file exists in SRC, this option is added to copy the target file pointed to by the soft connection to DST.

-P: Keep File Permissions

-O maintain the file owner information

-G: Keep file group information

-D. Keep the device file information.

-T preserve file time information

-- Delete: delete the files that are not in the SRC file in DST.

-- Exclude = PATTERN specifies to exclude files that do not need to be transmitted. The equal sign is followed by the file name. It can be in the universal character mode (for example, *. txt)

-- Progress can see the status of the synchronization process during the synchronization process, such as counting the number of files to be synchronized and the synchronization file transmission speed.

-U with this option, the new files in DST and SRC will be excluded and will not be overwritten.

There are only a few commonly used OPTION pages: (-a-v -- delete -- exclude -- no-OPTION)

(1) When using rsync to back up the directory locally, remember to include/
Mkdir test1
Cd test1
Touch 1.txt 2.txt

Rsync-av test1/test2/
# Otherwise, the test/directory will return to the newly generated test2/directory.

(2) -- no-OPTION

Rsync-av -- no-l # Remove soft links

(3) Option-L # copy the soft link source file to replace the soft link.

Host A 192.168.176.252

Host B 192.168.176.253

The/root/install. log of the host must be synchronized to the/tmp directory of the host.

Rsync-avL/root/install. log root@192.168.176.253:/tmp

Prompt to enter host B User root Password

 

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.