Rsync synchronizes hidden and excluded files

Source: Internet
Author: User
Rsync: basic syntax of the synchronization command rsync command option: the target Directory of the source directory. if the source directory is/var/www/, all files in the directory will be synchronized to the target directory, if it is written as/var/www/*, the hidden file in the current directory (the folder name or file name is ". but the hidden files in the subdirectories will still be synchronized. Suppose you want to exclude a file (or folder), can you use? Exclude. for example, to exclude the dir1 folder under the source directory, you can write it to/us.

Basic rsync command syntax

Rsync command option source directory target Directory

If the source directory is/var/www/, all the files in the directory will be synchronized to the target directory. if it is/var/www /*, the hidden file in the current directory (the folder name or file name is ". but the hidden files in the subdirectories will still be synchronized.

If you want to exclude a file (or folder), you can use? ExcludeFor example, to exclude the dir1 folder under the source directory, you can write it:

/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 use? Exclude-fromFor example:

/Usr/bin/rsync-vzrtopg? Exclude-from = exclude. list/var/www/src // var/www/dest

The exclude. list file specifies the list to be excluded, for example:

Dir1
[0-9] *
Dir2/. [a-z0-9] *
. Svn

It means to exclude all files and folders named by numbers in the/var/www/dir1,/var/www Directory, hidden files under the/var/www/dir2/directory, and/ var/www Directory all. svn folder, including. svn folder.

Note:Both exclude and exclude-from have two minus signs. if one is missing, the command line will not report an error, but the executed files or folders cannot be excluded.


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.