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