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


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 -)

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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