Rsync – How to Preserve Timestamps When Source Tree Has a Mounted Point

backuprsync

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

Best Answer

from man rsync:

   -t, --times                 preserve modification times

EDIT - to improve on this answer since it is not immediately obvious why this did not help OP:

OP is copying files from one filesystem to another and wanting to preserve c-time. Most people understand c-time to mean "create time" which is incorrect on most UNIX/Linux systems (Windows filesystems track "creation" or "birth" times).

For the most part, in UNIX and Linux, c-time is the timestamp used to record the last inode 'C'hange. An inode changes if any of its attributes are updated:

OP cannot preserve the c-time of their file's when they are brought onto a new filesystem. The creation of these files in the new filesystems is one of the conditions listed above (creation of inode/file).

/EDIT

Related Question