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


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

Re: Copy a file from local to network preserving timestamp

From vallor <vallor@cultnix.org>
Newsgroups comp.os.linux.misc
Subject Re: Copy a file from local to network preserving timestamp
Date 2024-08-22 07:09 +0000
Message-ID <lio6gnFc4mtU7@mid.individual.net> (permalink)
References <va50u0$3tav1$3@dont-email.me> <va6igk$a1bk$1@dont-email.me>

Show all headers | View raw


On Thu, 22 Aug 2024 05:32:04 -0000 (UTC), Lawrence D'Oliveiro
<ldo@nz.invalid> wrote in <va6igk$a1bk$1@dont-email.me>:

> On Wed, 21 Aug 2024 17:25:52 +0200, ambaraba wrote:
> 
>> 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 :-(
> 
> cp and rsync should work. You can verify this by trying your same
> commands between local volumes.
> 
> The fact that the commands don’t work on the file server sounds like the
> fault of the file server.

Or the file server protocol, or even the API available to cp(1).

The OP was about the "creation time", which is supported in
the Linux statx(2) call in the statx struct as
[...]
struct statx_timestamp stx_btime;  /* Creation */
[...]

The ext4 filesystem supports this, and you can see it if you run
stat(1) on a file:
# stat /etc/fstab
  File: /etc/fstab
  Size: 1100      	Blocks: 8          IO Block: 4096   regular file
Device: 10306h/66310d	Inode: 7602178     Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2024-08-21 22:00:01.907146964 -0700
Modify: 2024-07-23 20:59:27.235228009 -0700
Change: 2024-07-23 20:59:27.235228009 -0700
 Birth: 2023-10-12 05:05:55.902131998 -0700

"Birth" is the creation date.  I don't think cp(1)
duplicates that for a new file.  (And it wouldn't
make sense anyway, because it would be the "birth" of
a new file.)

You'll also note that utime(2) and utimes(2) only allow
setting the access and modification times on a file.  Please
correct me if I'm wrong, but I don't see a way to change
change time or birth time on a file.

-- 
-v System76 Thelio Mega v1.1 x86_64 NVIDIA RTX 3090 Ti
   OS: Linux 6.11.0-rc4 Release: Mint 21.3 Mem: 258G
   "The future isn't what it used to be."

Back to comp.os.linux.misc | Previous | NextPrevious in thread | Next 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