LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This 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


Reply
  Search this Thread
Old 04-16-2013, 08:50 AM   #1
trafikpolisen
Member
 
Registered: Jun 2008
Posts: 121

Rep: Reputation: 3
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..
 
Old 04-16-2013, 08:24 PM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
On the cli I'd use 'scp -p ...' see 'man scp'
Code:
    -p      Preserves modification times, access times, and modes from the
             original file.
 
Old 04-18-2013, 02:09 PM   #3
trafikpolisen
Member
 
Registered: Jun 2008
Posts: 121

Original Poster
Rep: Reputation: 3
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
 
Old 04-18-2013, 07:07 PM   #4
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
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.
 
Old 04-20-2013, 08:13 AM   #5
trafikpolisen
Member
 
Registered: Jun 2008
Posts: 121

Original Poster
Rep: Reputation: 3
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.
 
Old 04-22-2013, 02:26 AM   #6
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Assuming you've got the usual sudo setup that makes you root, that would explain it.
 
Old 05-12-2013, 08:38 AM   #7
trafikpolisen
Member
 
Registered: Jun 2008
Posts: 121

Original Poster
Rep: Reputation: 3
Quote:
Originally Posted by chrism01 View Post
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?
 
Old 05-14-2013, 10:13 AM   #8
trafikpolisen
Member
 
Registered: Jun 2008
Posts: 121

Original Poster
Rep: Reputation: 3
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..
 
Old 05-14-2013, 10:20 AM   #9
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,840

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
the only thing I can imagine is that mount and mount.cifs have different syntax, therefore you cannot use exactly the same command line...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell script on copying files and folders from a linux server to a windows server nithin6034 General 6 07-20-2011 07:59 AM
[SOLVED] copying files according to modification date and extension SriniKlr Linux - Newbie 5 01-03-2011 03:45 AM
Copying files from windows clients to linux server sarajevo Linux - Networking 2 05-17-2008 01:18 AM
Copying files from a specific date dman65 Linux - Software 3 09-22-2003 10:16 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:56 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration