How to Use rsync in Linux

Source: Internet
Author: User

How to Use rsync in Linux

For various organizations and companies, data is the most important to them. Even for e-commerce, data is equally important. Rsync is a tool/software that backs up important data through the network. It is also a network protocol for synchronizing folders and files between systems through the network on Unix-like and Window systems. Rsync can copy or display directories and copy files. Rsync listens to TCP port 873 by default and Copies files through remote shell such as rsh and ssh. Rsync must be installed on both the remote and local systems.

The main advantages of rsync are:

Speed: All content will be copied locally and remotely. Next time, only the changed block or byte will be transmitted.

Secure: data can be encrypted over ssh.

Low bandwidth: rsync can compress and decompress data blocks at both ends.

Syntax:

  1. # Rsysnc [options] source path destination path
Example: 1-enable Compression
  1. [Root @ localhost/] # rsync-zvr/home/aloft // backuphomedir
  2. Building file list... done
  3. . Bash_logout
  4. . Bash_profile
  5. . Bashrc
  6. Sent 472 bytes encoded ed 86 bytes 1116.00 bytes/sec
  7. Total size is324 speedup is0.58

The preceding rsync command uses-z to enable compression.-v is visualized and-r is recursive. The above is synchronized between the local/home/aloft/AND/backuphomedir.

Example: 2-Preserve the attributes of files and folders
  1. [Root @ localhost/] # rsync-azvr/home/aloft // backuphomedir
  2. Building file list... done
  3. ./
  4. . Bash_logout
  5. . Bash_profile
  6. . Bashrc
  7.  
  8. Sent 514 bytes encoded ed 92 bytes 1212.00 bytes/sec
  9. Total size is324 speedup is0.53

We used the-a option above, which retains the owner and group, timestamp, soft link, and permission and runs in recursive mode.

Example: 3-synchronize local data to a remote host
  1. Root @ localhost/] # rsync-avz/home/aloft/azmath@192.168.1.4: 192.168.1.4:/share/rsysnctest/
  2. Password:
  3.  
  4. Building file list... done
  5. ./
  6. . Bash_logout
  7. . Bash_profile
  8. . Bashrc
  9. Sent 514 bytes encoded ed 92 bytes 1212.00 bytes/sec
  10. Total size is324 speedup is0.53

The preceding command allows you to synchronize data between local and remote machines. As you can see, you are prompted to enter the password when Synchronizing files to another system. During remote synchronization, you must specify the user name and IP address or Host Name of the remote system.

Example: 4-remote synchronization to local
  1. [Root @ localhost/] # rsync-avz azmath@192.168.1.4: 192.168.1.4:/share/rsysnctest // home/aloft/
  2. Password:
  3. Building file list... done
  4. ./
  5. . Bash_logout
  6. . Bash_profile
  7. . Bashrc
  8. Sent 514 bytes encoded ed 92 bytes 1212.00 bytes/sec
  9. Total size is324 speedup is0.53

The preceding command synchronizes remote files to the local device.

Example: 5-find out the differences between files
  1. [Root @ localhost backuphomedir] # rsync-avzi/backuphomedir/home/aloft/
  2. Building file list... done
  3. Cd ++ backuphomedir/
  4. > F ++ backuphomedir/. bash_logout
  5. > F ++ backuphomedir/. bash_profile
  6. > F ++ backuphomedir/. bashrc
  7. > F ++ backuphomedir/abc
  8. > F ++ backuphomedir/xyz
  9.  
  10. Sent 650 bytes encoded ed 136 bytes 1572.00 bytes/sec
  11. Total size is324 speedup is0.41

The above command helps you find out the differences between the source address and the target address in the file or directory.

Example: 6-Backup

The rsync command can be used to back up linux.

You can use rsync in cron to schedule backups.

  1. 00 ***/usr/local/sbin/bkpscript &>/dev/null
  1. Vi/usr/local/sbin/bkpscript
  2.  
  3. Rsync-avz-e 'ssh-p2093 '/home/test/root@192.168.1.150:/Oracle/data/

Rsync + inotify implement real-time synchronization and backup of Git data

Rsync for file backup Synchronization

Rsync synchronizes two servers

Remote synchronization of Rsync in CentOS 6.5

Use Rsync in Ubuntu Linux for data backup and Synchronization

Linux uses the Rsync client to synchronize directories with the server for backup

Rsync details: click here
Rsync: click here

This article permanently updates the link address:

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.