Sujet : Re: Copy a file from local to network preserving timestamp
De : robin_listas (at) *nospam* es.invalid (Carlos E.R.)
Groupes : comp.os.linux.miscDate : 23. Aug 2024, 13:56:07
Autres entêtes
Message-ID : <7gdmpkx4rk.ln2@Telcontar.valinor>
References : 1
User-Agent : Mozilla Thunderbird
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.