'cp' skips some of Eclipse's dot directories

1

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

DDus

Posted 2010-01-14T17:33:00.547

Reputation: 111

Answers

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

mob

Posted 2010-01-14T17:33:00.547

Reputation: 262

0

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.

kdgregory

Posted 2010-01-14T17:33:00.547

Reputation: 211