How can I preserve file modification times when copying to a NAS?

I believe I have solved the problem. In Ubuntu 12.04, in Nautilus there are two ways to connect to the remote DiskStation NAS. One preserves modification times, one does not.

In the menu on the left-hand side of a Nautilus window, the Browse Network... button eventually leads to an AFP (Apple Filing Protocol) connection to the DiskStation, through which neither Nautilus nor cp -p copies preserve modification time. I tried disabling Apple support in the DiskStation, but in that mode the DiskStation wasn't even visible in Browse Network.

In Nautilus's File menu there is a Connect to Server... option that offers a host of protocols. I chose Windows, entered my credentials, and connected without trouble. In this mode, modification times are preserved, so I was able to re-copy my photos and have their dates preserved.

Thank you Sergey and david6 for your suggestions. Hopefully people will find this information valuable.


Standard cp command has --preserve flag which preserved certain attributes (by default - mode,ownership,timestamps) when copying.

So something like this:

cp -rp /source/photos/folder /destination/photos/folder

should do the trick in the "normal" case. However, the afp:// thing in the URL confuses me - is it Apple Filing Protocol? All bets are off in this case.

One think I'd like to add - relying on file modification dates for cataloging your photos is very fragile. This is what image metadata (EXIF etc.) is for. Or, at least, just put them in directories according to their shooting date: photos/2012/12/05 etc.


This is the classic push/pull problem, for remote copy.

The recipient host is not honouring the date-stamp of the received files. Nautilus has this same fault, from 10.04 LTS through 12.10 ..

This is solved (for Nautilus), when copying between two Ubuntu hosts, by always copying from the remote-host (source) to the local-host (recipient). (AKA 'PULL')


Your problem is with the NAS box, and not with Ubuntu.

You need it to honour the date-stamp of received files (by default).

Are you using NFS (Linux) or CIFS (Windows) for file sharing?