Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to implement rsync to synchronize hidden files and exclude files

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article focuses on "how to achieve rsync synchronization hidden files and exclude files", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "how to achieve rsync synchronization hidden files and exclude files"!

The basic Writing of rsync synchronization Command

Rsync command options source directory destination directory

If the source directory is written as / var/www/, all files in that directory will be synchronized to the destination directory, and if written as / var/www/*, then the hidden files in the current directory (the folder name or file name is "." Will not be synchronized, but the hidden files in the subdirectory will still be synchronized.

If you need to exclude a file (or folder), you can specify it with-exclude. For example, if you want to exclude the dir1 folder under the source directory, you can write:

/ usr/bin/rsync-vzrtopg-exclude=dir1 / var/www/src/ / var/www/dest

Multiple entries can be excluded at the same time, for example:

/ usr/bin/rsync-vzrtopg-exclude=dir1-exclude=dir2 / var/www/src/ / var/www/dest

In addition to the above method, you can also specify it with-exclude-from, for example:

/ usr/bin/rsync-vzrtopg-exclude-from=exclude.list / var/www/src/ / var/www/dest

Specify the list to exclude in the exclude.list file, for example:

Dir1 [0-9] * dir2/. [a-Z0-9] * .svn

It means to exclude all files and folders with numeric names in the / var/www/dir1, / var/www directories, hidden files in the / var/www/dir2/ directory, and all .svn folders in the / var/www directory, including .svn folders in their subdirectories.

Note: both exclude and exclude-from are preceded by two minus signs. If one is omitted, the command line will not report an error, but the files or folders that are executed cannot be excluded.

At this point, I believe that everyone on "how to achieve rsync synchronization hidden files and exclude files" have a deeper understanding, might as well to the actual operation of it! 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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report