Linux skips the specified directory when synchronizing files with CP and Rsync _linux

Source: Internet
Author: User
Tags rsync
The requirements are: a test site, in a node need to sync to the official site, but the Config directory inside can not cover,


Method One: Execute the following command at the terminal command line
Cp-r ' Find/projecta-type d-path/projecta/common/config-prune-o-print | Sed 1d '/projectb/

Method Two:

localhost # find Projectb/ommon/config | Xargs touch modifies the target directory's Congfig directory file access time to the current, so the update parameter can be bypassed by the CP
localhost # cp-r-u-v projecta/* projectb/This will not duplicate the first level of hidden directories below ProjectA, but level two three will still replicate the past

So it is more convenient to apply to the case without hidden directories.

But our project is involved in SVN or something, so there will be a lot of hidden directories containing version control information, it will be messy, so there is a second scenario

Method Three:

Rsync-vaup--exclude= ". *"--exclude= "Common/config" PROJECTA/PROJECTB

Under Simple annotation
-a parameter, equivalent to-rlptgod,-r is recursive-L is a linked file, meaning copy linked file,-p means to maintain the original permissions of the file,-T to maintain the original time of the file,-G to maintain the original user group,-O to maintain the original owner of the file;
-P transmission progress;
-V redundancy mode, look up the file list, etc.
-U update mode, if the destination file is new to the source file, skip
The first exclude represents skipping all. hidden files that begin with.
The second refers to the Projecta/common/config directory, because the Config directory of files, easy to change, if you need to manually adjust, note that this parameter is the relative path of the back src parameter

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.