1

Similar to but more demanding than this question : How to copy files while not modifying the file creation times at all?

I want to copy files between computers without the "Modified" and "Created" dates being messed with.

The purpose is to compare diffs of some project code in 3 different computers which I had managed to sync when I was working on them. But I worked on only one machine at a time, and now I don't remember which was the most updated one. It's a mess, and I want to unify the copies (and hopefully put it under version control) once and for all.

So when I use diff tools, knowing file modification dates can help me understand and merge changes.

2 of the 3 computers are linux, and 1 is Windows 8.

Any other ways of achieving the above, any best practices in such situations are welcome.

Milind R
  • 897
  • dd? Seriously though, why not simply start with git init and see where that takes you? – the Aug 03 '14 at 16:18
  • (1) The second answer on the question that you link to is “zip the files”. Why is this not good enough for you? (2) Linux, in general, does not maintain a file created date; so you’re asking for something that doesn’t (and *cannot*) exist. (3) Why isn’t modification date good enough your purposes? – Scott - Слава Україні Aug 04 '14 at 18:32
  • What about mounting the file systems on one of the Linux boxes? – Marcelo Aug 04 '14 at 22:24
  • 1
    I assume, the systems are connected over LAN. In such a case, you can just create a mapped drive ("Tools->Map network drive..." in explorer) and access the files from other system, without actually doing any copy/paste or changes to the attributes. – jjk_charles Aug 04 '14 at 23:35
  • dd is what I would use. http://www.linuxmanpages.com/man1/dd.1.php Run a Sha-1 Hash on the file before and after to make sure the image is a forensic duplicate. Make a bootable Kali disk, the commands are native and you can mount the fs in ro mode. – Ben Plont Aug 05 '14 at 22:18
  • Sha-1 command info: http://linux.about.com/library/cmd/blcmdl1_sha1sum.htm – Ben Plont Aug 05 '14 at 22:23
  • @KasperSouren see my comment – Milind R Aug 08 '14 at 19:16
  • @Marcelo How? Samba? I can't physically attach that hard disk to the linux machines. – Milind R Aug 08 '14 at 19:16
  • @jjk_charles map network drive on windows machine from linux machine using.... what? WebDAV? Samba? FTP? – Milind R Aug 08 '14 at 19:17
  • 1
    Yep. Samba/CIFS can mount windows shares on Linux. For the other Linux box, NFS would be fine. – Marcelo Aug 08 '14 at 19:19
  • @MilindR dd copies files bit by bit. exact duplicates. If you run a sha-1 hash on the source file it gives you that files thumbprint. If you run a sha-1 hash on the copy, and it matches the source file's Sha-1 hash, then you know your metadata is unchanged. That's why I would use that method. – Ben Plont Aug 08 '14 at 20:30
  • @MilindR, yes you can make use of Samba to achieve it. – jjk_charles Aug 08 '14 at 20:33

4 Answers4

1

Generally there are three attribute for file/folder. Creation, modification and access times. There is no much importantance in access time. In linux Creation time is not not used (and not accessible using standard procedures). So the only important attribute is modification time. While copying data with OS's tool modification time is not changed (at least for linux). If this is not the case you can compress the data before transfer and decompress it at the other end. Generally backup tools preserves all attributes.
If you want to strictly preserve all the attributes you can use the following methods.

cp with option -a a.k.a --archive or --preserve=all
or
rsync with -t.

These commands are available in linux by default (also downloadable for windows).
If you are not interested in commandline tools use a synchronization tool, that support attribute copy, to copy the data.

totti
  • 872
1

If you're not sure what's the best code on the computers, I think it's best to copy all three source directories on one machine, then merge file by file. Merge tools.

Another way would be to create a git repo on a machine, and copy sources from another computer, overwriting the git repo files, or just add them to a new branch, and then use git's merge. For Windows, I prefer Tortoise Git client for doing all the basic versioning stuff.

As for the metadata copy, as suggested by others, you can use rsync -t, cp --preserve=all. For FTP transfers, you can use scp -p.

  • I am certainly planning to use mercurial and version it up, but the date I last messed with one set of code is important in the decision-making involved in merging. – Milind R Aug 08 '14 at 16:11
0

Between the two Linux computers you can use rsync, it will keep time stamps as they are.
For Windows you can use robocopy to copy the files without changing the time stamps, maybe you can use it to copy the files from an FTP server in your Linux box to Windows.

0

On Linux (and other Unix-like OSes), you can copy files to and from a flash drive or from an SMB/FTP server with

cp -p

That should preserve timestamps.

I don't know if timestamps can be preserved when uploading to the server.

Karel Vlk
  • 203