LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 11-07-2012, 06:07 PM   #1
terence
LQ Newbie
 
Registered: Feb 2004
Location: Edinburgh UK
Distribution: CentOS
Posts: 6

Rep: Reputation: 0
cp -u copies old files that already exist in the destination directory



Hi,

I am using CentOS 5.8 x86_64. I have 2 hard disks, one containing the / paritition and all user files, and a 2nd one
which I use as a backup disk. I normally do a backup by using "cp -a -u" so only new files created since the last
backup need to be copied to the backup disk. I have been doing this for a number of years without any problems.
Recently, however, I noticed that the "cp -a -u" commands keeps trying to copy certain old files that already exist
on the backup disk (my cp command is aliased to "cp -i", so I get prompted whenever it tries to overwrite an existing
file). It only does this for a small number of old files, but it keeps doing it to the same old files every time I
execute "cp -a -u". I checked the time stamps of the files both on my home directory and the backup disk and they are
exactly the same (as they should be). I even tried to do a' touch' on the old files on the backup disk, so they end
up having a newer time stamp than the files on the home directory - to no avail: "cp -a -u" still tries to copy them.

Does anyone have an explanation for this strange behaviour, and how to fix it?

Thanks in advance,
Terence
 
Old 11-07-2012, 06:20 PM   #2
sag47
Senior Member
 
Registered: Sep 2009
Location: Philly, PA
Distribution: Kubuntu x64, RHEL, Fedora Core, FreeBSD, Windows x64
Posts: 1,431
Blog Entries: 33

Rep: Reputation: 358Reputation: 358Reputation: 358Reputation: 358
Why cp? Why not rsync? It's better for this sort of thing.

Code:
rsync -av /source /dest
 
Old 11-08-2012, 08:02 AM   #3
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 1,436

Rep: Reputation: 599Reputation: 599Reputation: 599Reputation: 599Reputation: 599Reputation: 599
Are you copying to any type of FAT filesystem? Those can only represent time to a resolution of 2 seconds, so any source file with an odd-number timestamp will appear to be 1 second newer than the destination. With rsync there is a "--modify-window=" option to mask that.
 
Old 11-08-2012, 04:07 PM   #4
terence
LQ Newbie
 
Registered: Feb 2004
Location: Edinburgh UK
Distribution: CentOS
Posts: 6

Original Poster
Rep: Reputation: 0
Thanks for your replies.

sag47: After posting my original question I discovered rsync and it works well, so in future I'll probably
use that. But this still doesn't explain the weird behaviour of 'cp -u', which as I said, only appeared
recently/ The only recent change to my set up is that I bought a new PC and re-organized my partitions
differently, but this should not have caused 'cp -u' to behave differently.

rknichols: No, I don't have any FAT filesystems, only ext2/3/4. Even if the time stamp resolution problem
also happens in ext2 filesystems, this still wouldn't explain why after doing a 'touch' on the destination
file several weeks after the original was created, the problem still recurs.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Rsync deleting files from destination directory Russell P Linux - Newbie 2 07-14-2011 11:07 AM
directory listing of files that don't exist! davidhaore Linux - Software 5 10-17-2010 08:21 PM
[SOLVED] [ask]Specifying destination directory when installing Slackware ethereal1m Linux - Newbie 2 01-25-2010 04:37 AM
thunar copies directory files to usb stick out of order. curmudgeonbob Linux - General 1 07-28-2009 11:59 AM
How to delete the destination files while the source files deleted in cp -u ? myunicom Linux - General 4 09-26-2003 01:13 PM


All times are GMT -5. The time now is 01:30 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration