Method of excluding one or more directories when Linux CP replicates directories

Source: Internet
Author: User
Tags rsync

The CP does not seem to exclude the directory functionality, you can use the rsync command to implement, such as:

Case

The/home/php-note directory contains the data directory, the data directory contains a, B, C, D, e five directories, now to the data directory in addition to the E directory of all directories copied to the/bak directory.

Operation

Yum Install rsync #安装rsync

cd/home/php-note/

Rsync-av--exclude data/a--exclude data/b--exclude data/c Data/bak

Note: The path behind the--exclude cannot be an absolute path, it must be a relative path, otherwise an error occurs.


CP exclusion File

CP-RF ' ls srcdir | Grep-e-V "^ (exclude_file|exclude_dir) $" ' destdir/

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.