9

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.

Jorge Castro
  • 73,717
Randall Cook
  • 4,155
  • 4
  • 19
  • 21

5 Answers5

5

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.

Randall Cook
  • 4,155
  • 4
  • 19
  • 21
2

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.

Sergey
  • 44,353
2

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?

david6
  • 14,528
  • 5
  • 38
  • 46
0

Turns out that preserving timestamps for files and directories is still a problem in 2019! I was copying files from an Ubuntu 16 machine to an Ubuntu 18 one over SFTP, using Nautilus on the Ubuntu 18, and all files had the current timestamp, but directories had the original timestamps. Other tools failed as well:

What did work was to mount the remote filesystem using sshfs:

$ sudo mkdir /mnt/remote-machine
$ sudo sshfs -o allow_other,default_permissions dandv@10.15.x.x:/ /mnt/remote-machine
$ cp -rp /mnt/remote-machine/path/to/files ./
$ # ... or use another file manager

Copying from the mounted path also enabled Midnight Commander to preserve the timestamps (but didn't help BeyondCompare).

0

To solve this issue on the client side, try specifying the protocol explicitly in mount options.

From man mount.cifs:

       vers=
           SMB protocol version. Allowed values are:
       ·   1.0 - The classic CIFS/SMBv1 protocol. This is the default.

       ·   2.0 - The SMBv2.002 protocol. This was initially introduced in
           Windows Vista Service Pack 1, and Windows Server 2008. Note that
           the initial release version of Windows Vista spoke a slightly
           different dialect (2.000) that is not supported.

       ·   2.1 - The SMBv2.1 protocol that was introduced in Microsoft
           Windows 7 and Windows Server 2008R2.

       ·   3.0 - The SMBv3.0 protocol that was introduced in Microsoft
           Windows 8 and Windows Server 2012.

       Note too that while this option governs the protocol version used,
       not all features of each version are available.

sudo mount -t cifs //mynas/Disk1share /mnt/Data/NAS -o user=me,password=mine,uid=$(id -u),vers=2.0
AnrDaemon
  • 113