Posted by & filed under Linux, Server Admin.

Scenario:

Folder /public_html looks like this:

/public_html
assets/
dev/
dev2/
code/
images/ 
css/
index.php

I need to clone all the files and folders (with a couple of exceptions) in this directory into the /public_html/dev folder. We need to exclude the dev/ folder as it is the destination, and also want to exclude the dev2/ folder.

Rsync makes this easy:

rsync -av --exclude='path1/to/exclude' --exclude='path2/to/exclude' source destination

In my scenario, something like the following gets the job done:

rsync -av --exclude='dev/' --exclude='dev2/' /public_html /public_html/dev

 

Leave a Reply

You must be logged in to post a comment.