Rsync Remote synchronization backup data (SSH mode)

Source: Internet
Author: User
Tags dedicated server rsync man rsync

I did not use, save the reference later

Reprint Source: Http://outofmemory.cn/wr/?u=http%3A%2F%2Fsmilejay.com%2F2012%2F02%2Frsync_remote%2F

Two days ago, I checked the department's test data and file backup situation, see the crontab has an rsync script, I look carefully, manual execution is actually not working properly, mainly because rsync there can not be automatic (need to enter the SSH login root password). Look, 1 years have not backed up, ⊙﹏⊙ b Khan, quickly fix this problem. And then by the way to learn about rsync remote backup things, write a blog to record it.

My favorite way to back up data:
For general scripts or documents, I generally use git repository management and backup, for many of the larger test data and procedures, I used a dedicated server to do the backup, mainly through the way of rsync daily backup.

Two modes of rsync remote synchronization:
Rsync connects to a remote host for synchronization or backup by using a remote shell program such as SSH or rsh, or by using TCP to connect to rsync daemon directly.
I used the SSH connection for rsync to sync.
When the host name of the source or destination path contains a colon separator, rsync uses a remote shell transport, and when the source or destination path's host name contains two colons, or uses Rsync://url, Rsync uses TCP to directly connect to the Rsync daemon.
In particular, if you specify only the source path and do not specify a destination path, rsync displays a list of files in the source path, similar to using the command ls-l. Rsync treats the local side as a client, and the remote side as a server.

My current common rsync remote sync commands are as follows:
rsync vmm-qa.smilejay.com:/home//share/home/-avz–delete
–delete Deleting unnecessary files (files not on the server side) from the destination directory
-A is equivalent to-rlptgod, so this-A is the most commonly used parameter.
When the above command synchronizes on the client side, you can see the following processes on the server side:
[root@myserver ~]# ps-ef | grep rsync | grep-v grep
root       7502  7500 21:36?        00:00:04 Rsync–server–sender- Vlogdtprz. /home/

rsync vgt.smilejay.com:/etc//share/temp/-avz-f–exclude Yum
-f–exclude ABC #同步时, excluding ABC this file or directory

Some of the options for the rsync command are as follows:
[Root@linux ~]# rsync [-avrlptgod] [e-SSH] [user@host:/dir] [/local/path]
Parameters:
-V: Observation mode, you can list more information;
-Q: Contrary to-V, quiet mode, the output of less information;
-R: Recursive system. Can be handled for "directory". Very important.
-U: Updates only (update), will not overwrite the target of the new file;
-L: Copy the properties of the link file, not the original file content of the linked object;
-P: When replicating, it is also saved with attributes (permission).
-G: Save the original file of the owning group;
-O: Save the owner of the original file;
-D: Appliance properties for saving original files (device)
-T: Save the time parameter of the original file;
-I: Ignoring the attributes of the update time (mtime), the file will be relatively fast;
-Z: plus the compressed parameters.
-e: Channel contracts used, for example, using the SSH channel, the-e ssh
-A: The equivalent of-rlptgod, so this-A is the most commonly used parameter.
For more information please refer to man rsync.

rsync Shell mode synchronization does not require a password method:
Because it is in fact the way to go ssh, so in accordance with SSH to configure key to achieve rsync without password.
I have written a blog about ssh password-free configuration:

I also encountered a problem, that is, my key is also ready, but it is not (or need to manually enter the password).
It turned out that sshd blocked the root user from SSH telnet, checked the server-side/etc/ssh/sshd.conf file, and changed one of its entries to:
Permitrootlogin Yes
SSH can then automatically login to achieve rsync password-free synchronization.

References to shell and daemon schemas for rsync:
http://share.blog.51cto.com/278008/560742
http://share.blog.51cto.com/ 278008/567578

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.