In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article will explain in detail how to parse the Rsync command 17 backup options, the content of the article is of high quality, so the editor to share with you to do a reference, I hope you have a certain understanding of the relevant knowledge after reading this article.
Backup often is a good habit, but such a good habit can only be formed reluctantly and slowly after countless times of pounding on the chest and rushing chagrin. The most common command for backup is:
Rsync-avl source destination
The short option a here is an abbreviation for the long option-archive. However, if we want to back up all the data when the system moves, use the-an option carefully. Because if you change a new user name on the new system, you will not be able to open all the data backed up with the-an option.
Why?
1) convenient but not simple-Archive option
Option-archive appears to represent only one indicative condition, but it is essentially a shortcut for multiple high-frequency options:
Rsync-a # is equivalent to-rlptgoD
In other words,-an option is equivalent to adding the seven options of-rlptgoD. This is the crux of the problem raised in the introduction.
-p-- perms # reserve permissions-o-- owner # retain owner-g-- group # synchronization group
The above three options, respectively, synchronize the permissions of the file, the master and the group; as a result, we can only view all backed up data with the current user. After switching users, there is no corresponding permission to view.
Therefore, when we reinstall the system to back up all data, we should be careful to use the-an option.
2) basic options commonly used
The basic options for rsync are:
-v-- verbose # reports the current progress in the terminal-- r-- recursive # Recursive mode-t-- times # synchronization timestamp-I-- ignore-times # out-of-Sync timestamp-l-- links # create soft connection-L,-- copy-links # copy the location that the soft connection points to-z,-- compress # allows compression-d -- dirs # only backup directory tree structure
The above eight option are the basic parts of the rsync command.
3) exclude and include specific files and directories
In the process of synchronization, we often need to exclude dot files, such as .git.ssh, etc., and the exclude command will have the opportunity to use its talents.
-- exclude= {.ssh, .git, .config}
The-exclude-from=FILE option provides a more intimate service, and we can write directories that we often exclude into special files. In this file, we can apply # and; Note that the rsync command is automatically ignored and blank lines are skipped.
The opposite of 'exclude'' is' include'. If we don't use {}, we can write it in a multi-line pattern:
Rsync-av ~ / Documents\-include=~/Public\-include=~/Music\-include=~/Videos\-include=~/Downloads\ / media/spiritme/disk/
In addition to include and exclude, rsync has options to implement filtering based on file size:
-- max-size=SIZE # filters files larger than this SIZE-- min-size=SIZE # excludes files smaller than this SIZE
4) the core of rsync command
The-update option is the soul of the rsync command. According to rsync's very considerate algorithm, files in destination whose timestamps are later than those in source will not be overwritten.
The-update option also works in conjunction with the-delete option, which removes redundant directories and files from destination.
Echoing the-delete option is the-existing option, which synchronizes only files that exist at the target location and does not create new files.
The above three options are the core of the rsync command.
We can also better monitor the progress of rsync and generate the final report.
-progress will print the progress of the file
782448 63% 110.64kB/s 0:00:04 # with-h
-I,-itemize-changes will generate a report of all changes.
5) change the options of rsync algorithm
The-W,-whole-file option changes the algorithm of rsync. Turn off its default delta-transfer algorithm and move the file as a whole. Of course, if rsync,-W is executed locally, it is the default behavior.
The-c,-checksum option will change rsync's default 'quick-check' algorithm.
6) closing summary
Starting from the permission problems caused by the specific problem 'rsync-a' command, we discuss the following step-by-step logic:
1) shortcuts rsync-a2) 8 basic options commonly used 3) methods to exclude and include specific files and directories 4) Core 5 of the rsync command) change the options of the rsync algorithm
This is the end of the 17 backup options on how to parse the Rsync command. I hope the above can be of some help and learn more. If you think the article is good, you can share it for more people to see.
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.