[SOLVED] Date preservation when copying files from Linux to Windows Server
Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Date preservation when copying files from Linux to Windows Server
I just noticed that when moving photos from my Linux Mint machine to my home server running Windows Server 2003, the "Modified" and "Accessed" dates gets replaced with the current date and time, which is really annoying. A few months ago i reinstalled my computer with Linux Mint 13, having previously used Ubuntu Lucid. When i used Ubuntu, the dates were preserved, so i figure it has to be some setting or problem related to samba.
I have tried using both Gnome Commander and Caja (Nautilus) with the same result.
BTW i wasn't quite sure where to post this thread, so feel free to move it..
I haven't tried scp, as I'd like to use my favorite file manager, which is Gnome Commander.
I use /etc/mdm/PostLogin/Default, which runs at every login, to execute something like the following line to connect to every share:
/sbin/mount.cifs //myserver/share $HOME/mountpoint -o credentials=$HOME/.smbcredentials,uid=$USER,iocharset=utf8,file_mode=0777,dir_mode=0777
It's not how the share is being mounted, it's how the files are being copied.
Code:
cp file /dest/
Will copy the file and timestamp the new version with the current time/date
Code:
cp --preserve=timestamps file /dest/
Will copy the file and timestamp the new version the same as the old
Since you're doing this through a file manager instead of the command line, there might be an unset option to preserve the timestamps during a copy. I'm pretty sure I've never used a Linux file manager, at least not in the last decade, so I can't help you there.
Ok, tried "cp --preserve=timestamps". File copies fine, but time is still not preserved and i get "Operation not permitted". However, if I do "sudo cp --preserve=timestamps", it works. Why? It used to work fine in Ubuntu and nothing is changed on the server since then, as far as I can remember.
Assuming you've got the usual sudo setup that makes you root, that would explain it.
But I'm still able to copy without root, it's just the date preservation that doesn't work.
Today I took the mount.cifs utility from Ubuntu Lucid and copied it to my Linux Mint computer. When i use the mount.cifs-version copied from Ubuntu Lucid to mount shares on my server, the dates are preserved when I copy files to the server. So the issue must be with the newer version of this utility.
I won't mark this thread as "Solved" as i don't know exactly what the fault is. Would it be safe to just use the Ubuntu version of mount.cifs, or could i run in to unexpected errors with data loss as the result?
Tried using "mount -t cifs" instead of the "mount.cifs"-tool and with this method it works! Can someone explain the difference between using the two methods? Bonus if you could explain why dates and times doesn't get preserved with mount.cifs, but not as important now that I seem to have found a solution that works. I'm going to do some more testing before marking as solved..
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.