Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I back up my pictures from my camera using rsync, using:

 rsync -vzrtl --progress --stats --timeout=0 host destination

Now I was in a different timezone when I did my first backup then I moved to a different timezone and I changed it on my laptop (I use ubuntu 10.04.4). Today I was backing up my pictures and I found that the timestamp were different (I mean the timestamps you can see with 'ls -lt'), so rsync would copy the whole directory (I always run rsync with the option -n first to know the list of files it would transfer). Now this is just stupid, because the files are actually the same. So I changed back to the previous timezone, in fact the file timestamps changed to the same on my camera - this I find weird somehow.

I run rsync again and the files are still different :@ Now, I don't want to copy the files again, this would be stupid, can you suggest a clean solution? How can I prevent this in the future? why the files are still different, if I changed to the previous timezone?


I found that the access and change time are different for the files, using stat. For example:

on host

   File: `DSC00003.JPG'
   Size: 3068392    Blocks: 6016       IO Block: 32768  regular file
 Device: 821h/2081d Inode: 2109        Links: 1
 Access: (0755/-rwxr-xr-x)  Uid: ( 1000/simona)   Gid: ( 1000/simona)
 Access: 2013-03-26 00:00:00.000000000 +0000 
 Modify: 2007-12-25 22:48:20.000000000 +0000
 Change: 2007-12-25 22:48:20.000000000 +0000

and on the destination

   File: `DSC00003.JPG'
   Size: 3068392    Blocks: 6008       IO Block: 4096   regular file
 Device: 802h/2050d Inode: 245762      Links: 1
 Access: (0755/-rwxr-xr-x)  Uid: ( 1000/simona)   Gid: ( 1000/simona)
 Access: 2013-03-26 10:24:49.000000000 +0000
 Modify: 2007-12-25 22:48:20.000000000 +0000
 Change: 2013-02-09 00:11:09.000000000 +0000

Is there a way to prevent rsync to overwrite pictures that have been modified more recently on the destination?

share|improve this question
1  
How did you set the timezone? And what is you BIOS clock set to? –  depquid Mar 26 '13 at 13:22
    
I set the timezone with the usual time tool on ubuntu, system->Administration->time and date. how do I check the bios clock? –  simona Mar 26 '13 at 14:03
    
See itconlor's answer about checking the hardware clock. –  depquid Mar 26 '13 at 18:06
add comment

1 Answer 1

To answer the question i make an assumption:

You are using rsync locally, transferring from a mounted SD-card to backup space

MMC are formatted with FAT-filesystems, so its always useful to set --modify-window=1 because FAT-filesystems store timestamps in a 2 second resolution.

man rsync gives the option --size-only which ignores the last-modified flag of the files. So only files with modified size, e.g. edited ones will be synced.

Another option would be to set the option --modify-window to the time difference between the two timzeones in seconds. e.g. for 2 hours use modify-window=3660 if there is a 1 hour difference

maybe the is a problem with your UTC setting.

You can check if your hardwareclock is set correct by typing date --utc Xour softwareclock is given by date.

The value should have the same difference as your local timezone to Greenwich Mean Time.

Your hardwareclock should always be set to UTC so all timestamps are set correct even when you change timezones(softwareclock).

If the UTC time is not correct, check if it ist set correct in your BIOS. If not, correct it.

If it is set you can check /etc/default/rcS. The should be the following line (Ubuntu 12.04)

#assume that the BIOS clock is set to UTC time (recommended)
UTC=yes
share|improve this answer
    
correct, I always use rsync locally for copying large number of files, because it's much faster than cp –  simona Mar 26 '13 at 15:19
add comment

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.