How to Use rsync in Linux for data backup, linuxrsync

Source: Internet
Author: User

How to Use rsync in Linux for data backup, linuxrsync

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.

how to speed up rsync transfers 

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.

speed up rsync

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

Syntax:
speed up rsync many small files
 
#rsysnc [options] source path destination path
Example: 1-enable Compression
 
[root@localhost /]# rsync -zvr /home/aloft/ /backuphomedir
building file list ... done
.bash_logout
.bash_profile
.bashrc
sent 472 bytes received 86 bytes 1116.00 bytes/sec
total size is 324 speedup is 0.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
 
[root@localhost /]# rsync -azvr /home/aloft/ /backuphomedir
building file list ... done
./
.bash_logout
.bash_profile
.bashrc
 
sent 514 bytes received 92 bytes 1212.00 bytes/sec
total size is 324 speedup is 0.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
 
root@localhost /]# rsync -avz /home/aloft/ azmath@192.168.1.4:192.168.1.4:/share/rsysnctest/
Password:

speed up rsync large files
 
building file list ... done
./
.bash_logout
.bash_profile
.bashrc
sent 514 bytes received 92 bytes 1212.00 bytes/sec
total size is 324 speedup is 0.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
 
[root@localhost /]# rsync -avz azmath@192.168.1.4:192.168.1.4:/share/rsysnctest/ /home/aloft/
Password:
building file list ... done
./
.bash_logout
.bash_profile
.bashrc
sent 514 bytes received 92 bytes 1212.00 bytes/sec
total size is 324 speedup is 0.53
The preceding command synchronizes remote files to the local device.

Example: 5-find out the differences between files
 
[root@localhost backuphomedir]# rsync -avzi /backuphomedir /home/aloft/
building file list ... done
cd+++++++ backuphomedir/
>f+++++++ backuphomedir/.bash_logout
>f+++++++ backuphomedir/.bash_profile
>f+++++++ backuphomedir/.bashrc
>f+++++++ backuphomedir/abc
>f+++++++ backuphomedir/xyz
 
sent 650 bytes received 136 bytes 1572.00 bytes/sec
total size is 324 speedup is 0.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.

 
0 0 * * * /usr/local/sbin/bkpscript &> /dev/null
 
vi /usr/local/sbin/bkpscript
 
rsync -avz -e ‘ssh -p2093′ /home/test/ root@192.168.1.150:/oracle/data/
Via: http://linoxide.com/how-tos/rsync-copy/

Related Article

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.