Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I recently installed a Synology DiskStation on my network. I mounted it from an Ubuntu 12.04.1 computer with the Browse Network button in Nautilus 3.4.2. It shows up as afp://randall@DiskStation.local/photo/ in Nautilus.

So far, so good. I then uploaded a lot of photos to it, all with modifications times covering several months. When I looked at the directory of photos on the DiskStation, they all had modification times for the moment they were copied, not the modification times on the source computer. So much for sorting them by date on the DiskStation.

Is there a way to re-copy the files but have their modification date be preserved? Perhaps I mounted the DiskStation the wrong way. Perhaps Nautilus was the wrong tool to use. Any suggestions?

BTW, I have moved gigabytes of photos to a different NAS (Plextor PX-EH) over SMB/CIFS from Ubuntu 10.04, 10.10, 11.04, and 11.10 with modification times fully preserved. The problem must be with the Synology or some Ubuntu 12.04 software.

share|improve this question
    
Does that NAS support SSH access? If yes you can use rsync or one of its GUI frontends to sync photos. Also, it should support SMB/CIFS too, which you can directly mount in Ubuntu and copy data with cp, rsync or any other tool. –  Sergey Dec 6 '12 at 8:02
    
rsync is the best copying/syncing tool to use. The -a (-rlptgoD) preserves modification time. See man rsync for more details. However, this requires SSH + rsync on both hosts. –  Terry Wang Dec 6 '12 at 10:38

3 Answers 3

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.

share|improve this answer
    
Thanks for the tip, Sergey. If I have to use the command line, I will, but I was hoping that Ubuntu would be able to do the right thing through the GUI. It has in the past (pre-12.04). And yes, I was about to move the photos to folders organized by month when I noticed the modification time problem. –  Randall Cook Dec 6 '12 at 7:48
    
I tried cp -p from a terminal and I got this error: "cp: preserving times for '.gvfs/AFP volume photo for randall on DiskStation/target_dir/image.JPG': Operation not supported". So I guess cp -p won't work. I'll try david6's suggestion. –  Randall Cook Dec 8 '12 at 6:35
    
When using Mac OS to access the Synology NAS via terminal, cp -p does not preserve the time stamps. I've mounted the NAS via smb. I asked Synology support, and apparently the lack of preservation is the default behavior. On the other hand, rsync does preserve time stamps. –  andrewj Jun 18 '13 at 19:53

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?

share|improve this answer
    
Thanks, david6. I'm definitely not using NFS, as it is disabled on the DiskStation, but Windows and Mac file sharing are enabled. When I connect to the DiskStation, Nautilus (I guess) only asks me for a username and password, not a protocol. The mount I get has "AFP" in its name, so I guess it chose the Apple file protocol. I'll try forcing a CIFS mount, see if that works, and then find a way to automatically get that. –  Randall Cook Dec 8 '12 at 6:50
up vote 1 down vote accepted

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.

share|improve this answer

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.