I use a Python backup script for my files and I back up from my hard drive to both pen drives that are detached from my PC and permanently attached external drives.
I have logic in my script that does a copy from source to destination only if the source file is newer.
If the destination file is newer, I just report an error and don't do any copy.
This works well for the permanently attached external drives. But for the the pen drives, for most of the files, the destination file is reported as being newer than the source file.
I use my pen drives for backups only and never for anything else. So it is impossible for files on the pen drives to be newer.
What could be the problem?
Thank you, Vishy
You could have come across a problem with different time stamps on different file system types. Since you post so little information on these, I have to take a wild guess.
The mechanism I'm thinking about is this:
Your original file system of type A (e. g. ext3fs, reiserfs, ntfs, ...) might contain time stamps for each file which have a precision of milliseconds. The backup file system (e. g. fat32, ...) might have a different precision for the time stamps (e. g. only seconds). During creation of the backup the system will have to decide how to handle that. The millisecond information must be lost, and maybe the value gets rounded, so a 12:23:34.789 might be rounded to a 12:23:35. (This of course should apply to around 50% of the files.)
When comparing file times, depending on the cleverness of the routines, this result might be interpreted as "the backup is newer than the original".
As I said, this is just a wild guess, so you should have a look at the concrete time stamps to find out.