Super User is a question and answer site for computer enthusiasts and power users. 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 am trying to backup my Eclipse .metadata directory. The command I run is:

cp -Rf ~/some/where/.metadata/* ~/some/backup/.metadata/.

The first time I tried this, the copy skipped the lock file and the .plugins and .mylyn directories. After doing some research, I found some threads mentioning permission changes. I applied the changes and found some success.

Now, running the script will not create or traverse into the .plugins or .mylyn directories. Additional research has come up with zero results.

I am using:

Windows XP SP 3

Cygwin 1.7.1-1

share|improve this question

migrated from Jan 14 '10 at 17:56

This question came from our site for professional and enthusiast programmers.

The wildcard character * in ~/some/where/.metadata/* does not match files or directories that begin with a dot. This is the behavior of most shells, not just Cygwin. Some alternatives:

  • Use another argument to explictly include dot files
    cp -Rf ~/some/where/.metadata/* ~/some/where/.metadata/.* ~/some/backup/.metadata/.

(.* does match files and directories that begin with two or more dots)

  • Use an expression that doesn't use the wildcard:
    cp -Rf ~/some/where/.metadata/ ~/some/backup/
  • Use the tar cf - | tar xf - idiom
    tar cf - ~/some/where/.metadata | (cd ~/some/backup/.metadata ; tar xf -)
share|improve this answer

I prefer using rsync or cpio to copy directories:

rsync -acv --delete . DST

find . | cpio -pudvm DST

I suspect I'm one of the few people to use cpio; it's an old habit from working on SysV machines. It has the drawback that you have to copy from the current directory: if you pass an absolute path to find, that path will be replicated in the destination directory. On the other hand rsync has its own weirdness depending on whether the SRC directory has a trailing slash.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .