Use rsync in ubuntu for Synchronous server backup

Source: Internet
Author: User
Tags rsync

By default, rsync is installed in ubuntu. You can run the rsync-h command to check whether the tool is installed. If not, run the following command:

$ Aptitude install rsync
 

Install.

Rsyncremote synchronize) is a remote data synchronization tool that can be used to synchronize files between local and remote hosts using the "Rsync algorithm.

The advantage of rsync is that only two different parts of the file are synchronized, and the same part is not transmitted. Similar to Incremental backup,

This saves a lot of time than the scp tool for transferring backup files or Synchronizing files on the server.

Specific usage:

1. Synchronize the two directories on the local machine

$ Rsync-zvr filename1 filename2
 

The above code is to synchronize the files in filename1 with the files in filename2. If you synchronize the files in filename2 to filename1, modify the code:

$ Rsync-zvr filename2 filename1
Parameter description:

-Z: Enable Compression

-V details output

-R indicates Recursion

2. Use rsync-a to synchronize the retention time by tag

$ Rsync-azv filename1 filename2
 

Use the preceding command to synchronize the files in filename2 at the same time as the files created in filename1,

It retains symbolic links, permissions, time tags, user names, and group names.

3. Synchronize files locally to the remote server

$ Rsync-avz filename1 ubuntu@192.168.0.1:/home/ubuntu/filename2
The above command is to synchronize local filename1 to the host of remote 192.168.0.1.

Note: If the remote host port is not the default port 22 and port 3000, change the preceding command,

$ Rsync-avz'-e ssh-p 4000 'filename1 ubuntu@192.168.0.1:/home/ubuntu/filename2
 

4. Synchronize the files on the remote server to the local device.

Similar to step 3, you only need to change the location of filename1 and the remote server,

$ Rsync-avz ubuntu@192.168.0.1:/home/ubuntu/filename2 filename1
 

Similarly, if the port is not 22, run the following command:

$ Rsync-avz'-e ssh-p 4000 'ubuntu@192.168.0.1:/home/ubuntu/filename2 filename1

Address: http://blog.sina.com.cn/s/blog_5d239b7f0100zbyq.html

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.