Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.os.linux.misc > #58147

Re: Copy a file from local to network preserving timestamp

From "Carlos E.R." <robin_listas@es.invalid>
Newsgroups comp.os.linux.misc
Subject Re: Copy a file from local to network preserving timestamp
Date 2024-08-23 14:56 +0200
Message-ID <7gdmpkx4rk.ln2@Telcontar.valinor> (permalink)
References <va50u0$3tav1$3@dont-email.me>

Show all headers | View raw


On 2024-08-21 17:25, ambaraba wrote:
> I would like to copy a file
> from srcdir [local HDD "UUID=5AAAA.. /mnt/srcdir  ntfs-3g" in fstab]
> to destdir [network share "//192.168.xx.xx /mnt/destdir ... cifs ..." in 
> fstab]
> preserving the original creation date.
> I've tried
>  > cp -p /mnt/srcdir/FILE.jpg /mnt/destdir/FILE.jpg
>  > rsync -vuart /mnt/srcdir      /mnt/destdir
>  > dd ... can't remember the options
> I've also tried with "freefilesync"
> Unfortunately the timestamp on the destination is not preserved :-(
> Is it there a way to
> copy a file (many files) from local to network share
> preserving timestamp ?
> I'm considering "timeshift" but honestly ...
> THANKS for any help

You have to consider that Linux uses three timestamps, but FAT/NTFS 
volumes don't.

I just ran a test, using an external usb memory stick formatted FAT. The 
time stamp is kept if I use "cp -a":

cer@Telcontar:~> l p
-rw-r--r-- 1 cer users 140 May 25 14:14 p
cer@Telcontar:~> cp p /media/D80B-80D3/
cer@Telcontar:~> l /media/D80B-80D3/p
-rw-r--r-- 1 cer users 140 Aug 23 14:42 /media/D80B-80D3/p
cer@Telcontar:~>

cer@Telcontar:~> stat /media/D80B-80D3/p
   File: /media/D80B-80D3/p
   Size: 140       	Blocks: 64         IO Block: 32768  regular file
Device: 841h/2113d	Inode: 2576        Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1000/     cer)   Gid: (  100/   users)
Access: 2019-08-04 02:00:00.000000000 +0200
Modify: 2024-08-23 14:42:54.000000000 +0200
Change: 2024-08-23 14:42:54.980000000 +0200
  Birth: -
cer@Telcontar:~>


You see that it is not kept with plain "cp". But:

cer@Telcontar:~> rm /media/D80B-80D3/p
cer@Telcontar:~> cp -a p /media/D80B-80D3/
cer@Telcontar:~> l /media/D80B-80D3/p
-rw-r--r-- 1 cer users 140 May 25 14:14 /media/D80B-80D3/p
cer@Telcontar:~> stat /media/D80B-80D3/p
   File: /media/D80B-80D3/p
   Size: 140       	Blocks: 64         IO Block: 32768  regular file
Device: 841h/2113d	Inode: 2582        Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1000/     cer)   Gid: (  100/   users)
Access: 2024-08-23 02:00:00.000000000 +0200
Modify: 2024-05-25 14:14:42.000000000 +0200
Change: 2024-08-23 14:44:07.900000000 +0200
  Birth: -
cer@Telcontar:~>


Let's have a look at a random file on the stick:

cer@Telcontar:~> stat /media/D80B-80D3/elements.txt
   File: /media/D80B-80D3/elements.txt
   Size: 117       	Blocks: 64         IO Block: 32768  regular file
Device: 841h/2113d	Inode: 2575        Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1000/     cer)   Gid: (  100/   users)
Access: 2024-08-23 02:00:00.000000000 +0200
Modify: 2018-12-17 19:53:36.000000000 +0100
Change: 2018-12-17 20:23:51.000000000 +0100
  Birth: -
cer@Telcontar:~>


The "Access" timestamp is the same in both files, so it is not true.



cer@Telcontar:~> l p
-rw-r--r-- 1 cer users 140 May 25 14:14 p
cer@Telcontar:~> stat p
   File: p
   Size: 140       	Blocks: 8          IO Block: 4096   regular file
Device: 825h/2085d	Inode: 2901704     Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1000/     cer)   Gid: (  100/   users)
Access: 2024-08-23 14:42:54.982156242 +0200
Modify: 2024-05-25 14:14:42.845777574 +0200
Change: 2024-05-25 14:14:42.845777574 +0200
  Birth: 2024-05-25 14:14:42.845777574 +0200
cer@Telcontar:~>





-- 
Cheers, Carlos.

Back to comp.os.linux.misc | Previous | NextPrevious in thread | Find similar


Thread

Copy a file from local to network preserving timestamp ambaraba <ambaraba@none.nn> - 2024-08-21 17:25 +0200
  Re: Copy a file from local to network preserving timestamp The Natural Philosopher <tnp@invalid.invalid> - 2024-08-21 16:40 +0100
  Re: Copy a file from local to network preserving timestamp Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2024-08-21 16:05 +0000
    Re: Copy a file from local to network preserving timestamp ambaraba <ambaraba@none.nn> - 2024-08-21 19:04 +0200
  Re: Copy a file from local to network preserving timestamp "186282@ud0s4.net" <186283@ud0s4.net> - 2024-08-22 00:16 -0400
  Re: Copy a file from local to network preserving timestamp Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-08-22 05:32 +0000
    Re: Copy a file from local to network preserving timestamp vallor <vallor@cultnix.org> - 2024-08-22 07:09 +0000
  Re: Copy a file from local to network preserving timestamp "Carlos E.R." <robin_listas@es.invalid> - 2024-08-23 14:56 +0200

csiph-web