Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm trying to copy only changed files using 'cp -pu' under Linux (Red Hat 6.1, source/destination FS are GlusterFS mounted partitions) but I found that it still tries to copy file seemingly old and unchanged. In fact, just running the same command again would skip to the next file. I can reproduce the problem in the test shown below. Notice that in the test, I hit control-C to stop the interactive cp command the each time it asks. The second run would skip the file asked in the first run. Why does this happen? And is there a better, fast standard tool to copy locally mounted directories? (I could probably try rsync but I don't need to be super accurate since the data are only for testing and I'm concerned about its speed.)

 [root@flex 6b42]# for d in *.story; do echo trying $d; ls -al $d
 /data/staging/./storage01/42/6b/6b42/$d; cp --parent -rpu -v -i $d
 /data/staging/./storage01/42/6b/6b42/; done trying
 0a65b244-f342-a120-9a47-62d0c6aa4a26.story
 0a65b244-f342-a120-9a47-62d0c6aa4a26.story: total 228 drwxrwx---    2
 somebody somebody     53 Jan  8 02:23 . drwxrwx--- 1280 somebody
 somebody 147456 Apr 30 11:07 ..
 -rw-r--r--    1 somebody somebody   2821 Nov 28  2011 data
 -rw-r--r--    1 somebody somebody      0 Nov 28  2011 images
 -rw-r-----    1 somebody somebody     17 Nov 28  2011 .timestamp

 /data/staging/./storage01/42/6b/6b42/0a65b244-f342-a120-9a47-62d0c6aa4a26.story:
 total 228 drwxrwx---    2 somebody somebody     53 Jan  8 02:23 .
 drwxrwx--- 1363 somebody somebody 155648 Apr 30 11:07 ..
 -rw-r--r--    1 somebody somebody   2821 Nov 28  2011 data
 -rw-r--r--    1 somebody somebody      0 Nov 28  2011 images
 -rw-r-----    1 somebody somebody     17 Nov 28  2011 .timestamp cp: overwrite
 `/data/staging/./storage01/42/6b/6b42/0a65b244-f342-a120-9a47-2d0c6aa4a26.story/.timestamp'?
 ^C [root@flex 6b42]# for d in *.story; do echo trying $d; ls -al $d
 /data/staging/./storage01/42/6b/6b42/$d; cp --parent -rpu -v -i $d
 /data/staging/./storage01/42/6b/6b42/; done trying
 0a65b244-f342-a120-9a47-62d0c6aa4a26.story
 0a65b244-f342-a120-9a47-62d0c6aa4a26.story: total 228 drwxrwx---    2
 somebody somebody     53 Jan  8 02:23 . drwxrwx--- 1286 somebody
 somebody 147456 Apr 30 11:07 ..
 -rw-r--r--    1 somebody somebody   2821 Nov 28  2011 data
 -rw-r--r--    1 somebody somebody      0 Nov 28  2011 images
 -rw-r-----    1 somebody somebody     17 Nov 28  2011 .timestamp

 /data/staging/./storage01/42/6b/6b42/0a65b244-f342-a120-9a47-62d0c6aa4a26.story:
 total 228 drwxrwx---    2 somebody somebody     53 Jan  8 02:23 .
 drwxrwx--- 1363 somebody somebody 155648 Apr 30 11:07 ..
 -rw-r--r--    1 somebody somebody   2821 Nov 28  2011 data
 -rw-r--r--    1 somebody somebody      0 Nov 28  2011 images
 -rw-r-----    1 somebody somebody     17 Nov 28  2011 .timestamp trying 0aee088d-af48-1236-bcae-6d2033a2acb7.story
 0aee088d-af48-1236-bcae-6d2033a2acb7.story: total 232 drwxrwx---    2
 somebody somebody     53 Jan  7 09:39 . drwxrwx--- 1286 somebody
 somebody 147456 Apr 30 11:07 ..
 -rw-r--r--    1 somebody somebody   5952 Dec 19 12:40 data
 -rw-r--r--    1 somebody somebody      0 Dec 19 12:40 images
 -rw-r-----    1 somebody somebody     17 Dec 19 12:40 .timestamp

 /data/staging/./storage01/42/6b/6b42/0aee088d-af48-1236-bcae-6d2033a2acb7.story:
 total 232 drwxrwx---    2 somebody somebody     53 Jan  7 09:39 .
 drwxrwx--- 1363 somebody somebody 155648 Apr 30 11:07 ..
 -rw-r--r--    1 somebody somebody   5952 Dec 19 12:40 data
 -rw-r--r--    1 somebody somebody      0 Dec 19 12:40 images
 -rw-r-----    1 somebody somebody     17 Dec 19 12:40 .timestamp cp: overwrite
 `/data/staging/./storage01/42/6b/6b42/0aee088d-af48-1236-bcae-6d2033a2acb7.story/.timestamp'?
 ^C
share|improve this question

1 Answer 1

cp --update doesn't check if the files are different, it just compares timestamps.

Rsync, which you seem to know about already, sounds like a good fit for your situation.

Use rsync -av $d/ /data/staging/./storage01/42/6b/6b42/$d/

share|improve this answer
    
Yes, I know the difference between cp and rsync. And I just tried out rsync, it apparently got the same problem too. so I think this could be a file system issue? Also, I mistakenly said it is an NFS mount but it is in fact a Glusterfs mount. Maybe the bug is in gluster? –  Hacking Bear Jun 8 '12 at 17:53
    
Maybe a timestamp issue? stat the files and compare. Also try the -c flag with rsync which compares files based on checksums instead of size & modification time; this may be a bit slower, though. –  Ankur Jun 10 '12 at 7:41

Your Answer

 
discard

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.