In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to use rsync to compare and synchronize files under Linux". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to use rsync to compare and synchronize files under Linux.
Exclude file and directory lists
Sometimes, when we do a lot of synchronization, we may want to exclude a list of files and directories from the synchronized files and directories. Generally speaking, it is not appropriate to synchronize files such as device files and certain system files, or files that take up unnecessary disk space, such as temporary files or cache files, which we need to exclude.
First, let's create a file called "excluded" (you can name it whatever you want, of course), and then write the folder or file we want to exclude to it, one line at a time. In our example, if you want to make a full backup of the root partition, you should exclude some of the device directories created at startup and the directories where temporary files are placed. The list looks like this:
You can then run the following command to back up the system:
The code is as follows:
$sudo rsync-aAXhv-exclude-from=excluded / / mnt/backup
Exclude files from the command line
You can also exclude files directly from the command line, which is useful when you want to exclude a small number of files and when you want to script it or add it to crontab without script or cron relying on another file to run.
For example, if you want to synchronize / var to a backup directory, but you don't want to contain folders such as cache and tmp, which usually don't have important content, you can use the following command:
The code is as follows:
$sudo rsync-aAXhv-- exclude= {"/ var/cache", "/ var/tmp"} / var/ home/adrian/var
This command is easy to use in scripts or cron and does not depend on other files.
At this point, I believe you have a deeper understanding of "how to use rsync to compare and synchronize files under Linux". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.