In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "how to use rsync under Linux". In daily operation, I believe many people have doubts about how to use rsync under Linux. Xiaobian consulted all kinds of information and sorted out simple and easy to use operation methods. I hope to help you answer the doubts about "how to use rsync under Linux"! Next, please follow the small series to learn together!
For organizations and companies, data is the most important thing, even for e-commerce. Rsync is a tool/software for backing up important data over the network. It is also a network protocol for synchronizing folders and files between systems over the network on Unix-like and Window Systems. Rsync can copy or display directories and copy files. Rsync listens on TCP port 873 by default and copies files through remote shells such as rsh and ssh. Rsync must be installed on both remote and local systems.
The main benefits of rsync are:
Speed: Initially copies everything locally and remotely. Next time, only the changed blocks or bytes are transmitted.
Security: Transfers can encrypt data via the SSH protocol.
Low bandwidth: rsync can compress and decompress data blocks at both ends.
Syntax:
#rsysnc [options] source path destination path Example: 1 -enable compression [root@localhost /]# rsync -zvr /home/aloft/ /backuphomedirbuilding file list... done.bash_logout.bash_profile.bashrcsent 472 bytes received 86 bytes 1116.00 bytes/sectotal size is 324 speedup is 0.58
The rsync command above uses-z to enable compression, -v for visualization, and-r for recursion. The above synchronizes between local/home/aloft/and/backuphomedir.
Example: 2 -Preserve properties of files and folders [root@localhost /]# rsync -azvr /home/aloft/ /backupholomedirbuilding file list... done./. bash_logout.bash_profile.bashrc sent 514 bytes received 92 bytes 1212.00 bytes/sectotal size is 324 speedup is 0.53
Above we used the-a option, which preserves everyone and group, timestamps, soft links, permissions, and runs in recursive mode.
Example: 3 -Sync local to remote host root@localhost /]# rsync -avz /home/aloft/ azmath@192.168.1.4: 192.168.1.4:/share/rsysnctest/Password: building file list... done./. bash_logout.bash_profile.bashrcsent 514 bytes received 92 bytes 1212.00 bytes/sectotal size is 324 speedup is 0.53
The commands above allow you to synchronize between local and remote machines. You can see that you are prompted for a password when syncing files to another system. To do remote synchronization, you need to specify the username and IP or hostname of the remote system.
Example: 4 -Remote sync to local [root@localhost /]# rsync -avz azmath@192.168.1.4: 192.168.1.4:/share/rsysnctest/:building file list... done./. bash_logout.bash_profile.bashrcsent 514 bytes received 92 bytes 1212.00 bytes/sectotal size is 324 speedup is 0.53
The above command synchronizes remote files to local.
Example: 5 -Find differences between files [root@localhost backuphomedir]# rsync -avzi /backuphomedir /home/aloft/building file list... donecd+++++++ 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/sectotal size is 324 speedup is 0.41
The above commands help you find file or directory differences between source and destination addresses.
Example: 6 -Backup
The rsync command can be used to backup linux.
You can schedule backups in cron using rsync.
0 0 * * * /usr/local/sbin/bkpscript &> /dev/nullvi /usr/local/sbin/bkpscript rsync -avz -e ‘ssh -p2093′ /home/test/ root@192.168.1.150:/oracle/data/
At this point, the study of "how to use rsync under Linux" is over, hoping to solve everyone's doubts. Theory and practice can better match to help everyone learn, go and try it! If you want to continue learning more relevant knowledge, please continue to pay attention to the website, Xiaobian will continue to strive to bring more practical articles for everyone!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.