how to tell rsync to preserve time stamp on files when source tree has a mounted point

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:

  • creation (OP's case)
  • mode (permissions)
  • owner/group
  • hard link count
  • etc. (stat() system call)

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


as hr3miller already said, -a (or --archive) is equal to -rlptgoD and already includes syncing time.

However when rsync copies data to, eg. an NFS/FAT32/NTFS mount where preserving user and owner fails, rsync won't try to set the time. Rsync will warn with something like

rsync: chown "/mnt/backup/postgres/hourly.0/primary/var" failed: Operation not permitted (1)

Therefore leave out preserving user and group by using

-rlptD

instead of

-rlptgoD

Only use this when not preserving the owner and group is an option for you. Note that preserving symlinks and other features could trigger that behavior, too. You will have to go through the man page for every rsync feature (-r -l -p -t -g -o -D) you want to backup.

Tags:

Backup

Rsync