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.

Related to this question

Short description of the problem:

When source tree has a mounted point inside it, then time stamps on files inside that mounted point when copied to target tree are not preserved even when using -a option

Detailed description:

Assume this is the source tree:

                       /home/                           /home/
                         |                                |
                        me/                             BACKUP/
                         |                                |
                    +----+----------+                +----+-------+
                    |    |          |                |    |       |
                 data/  foo.txt    boo.txt         data/ foo.txt boo.txt
                    |                                |
                   a.txt                           a.txt

where data/ above is mounted external USB disk. Everything is ext4 file system. Everything in source is owned my me.

BACKUP also happened to be a mount point, the backup USB disk.

After issuing this command rsync -av --delete /home/me/ /home/BACKUP/, I found that /home/BACKUP/data/ and everything below it has the current time stamp, as if these files were created now, and not the time stamp on the files in /home/me/data/. Other files and folders outside data did have the time stamp preserved OK.

Question is: How to use rsync in the above setting to tell it to preserve time stamps on all files and folders even on files and folders on a mounted point?

I am using:

>uname -a
Linux 3.5.0-17-generic #28-Ubuntu SMP x86_64 x86_64 x86_64 GNU/Linux

>rsync -v
rsync  version 3.0.9  protocol version 30
share|improve this question
add comment

1 Answer 1

up vote 3 down vote accepted

from man rsync:

   -t, --times                 preserve modification times
share|improve this answer
1  
Thank you. I know that. But please read the question again carefully. I did use -a which says: archive mode; equals -rlptgoD therefor -t is already included. –  Nasser Jan 17 '13 at 7:11
    
are you trying to preserve change time? ctime is NOT for "created" its for (status) change –  h3rrmiller Jan 17 '13 at 7:22
    
I want it to work just like it does on files that are not on the mounted disk. i.e. keep the same time stamp that one sees when doing ls -l on the file. This works on files that are not inside the mount point. But all files that are inside the mount point, have time stamp on them indicating they were just created. Whatever you call this time. I just wanted it to use the same time stamp on the files in the source. Now it does not. I want all time aspects be copied. i.e. a clone of the file be made. creation time, change time, etc... –  Nasser Jan 17 '13 at 7:31
    
the change time (ctime) gets updated upon a change to the inode (ie. creation/permission change/moving/etc). because you are creating a new inode (because you are copying the file accross a filesystem (separate inode tables) the ctime is updated. there is no way around that because it is the change of the inode, not the file. take a look at en.wikipedia.org/wiki/Stat_(system_call)#ctime –  h3rrmiller Jan 17 '13 at 8:01
    
ls -l shows mtime (modify) not ctime –  h3rrmiller Jan 17 '13 at 8:03
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.