Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to mirror a directory using lftp but I want to exclude certain subdirectories.

I tried

mirror -R -e -x ^\.svn$ /documents/ /test


mirror -R -e -x /^\.svn$/ /documents/ /test

but neither of them excluded the .svn directories.

share|improve this question
up vote 5 down vote accepted

mirror -R -e -x ^\.svn$ /documents/ /test is just fine.

The trick is, as .svn is a directory it will only be matched by a pattern that ends in a slash:

mirror -R -e -x ^\.svn/$ /documents/ /test

share|improve this answer

I'm using

--exclude /\..+/$

to exclude all folders starting with a dot.

share|improve this answer

From my experiments, it seems the include and exclude patterns are matched against the whole path with no initial / but with a trailing / for a directory.

Thus if you're trying to match a directory name like .svn which can occur at any level in the tree, you need this RE:


The ^ alternative matches .svn at the top level and the / alternative matches any level below that.

The | character is significant to lftp so needs to be sloshed.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.