From owner-freebsd-questions@freebsd.org Thu Oct 1 04:24:31 2020 Return-Path: Delivered-To: freebsd-questions@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 710913F1CE3 for ; Thu, 1 Oct 2020 04:24:31 +0000 (UTC) (envelope-from bennett@sdf.org) Received: from mx.sdf.org (mx.sdf.org [205.166.94.24]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "mx.sdf.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4C20Q634QWz4DVM for ; Thu, 1 Oct 2020 04:24:30 +0000 (UTC) (envelope-from bennett@sdf.org) Received: from sdf.org (IDENT:bennett@miku.sdf.org [205.166.94.6]) by mx.sdf.org (8.15.2/8.14.5) with ESMTPS id 0914OHUi020896 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits) verified NO); Thu, 1 Oct 2020 04:24:18 GMT Received: (from bennett@localhost) by sdf.org (8.15.2/8.12.8/Submit) id 0914OZ9Y029194; Wed, 30 Sep 2020 23:24:35 -0500 (CDT) From: Scott Bennett Message-Id: <202010010424.0914OZ9Y029194@sdf.org> Date: Wed, 30 Sep 2020 23:24:35 -0500 To: Polytropon , freebsd-questions@freebsd.org Subject: Re: Preserving target file's creation date User-Agent: Heirloom mailx 12.5 6/20/10 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 4C20Q634QWz4DVM X-Spamd-Bar: -- X-Spamd-Result: default: False [-2.23 / 15.00]; FAKE_REPLY(1.00)[]; ARC_NA(0.00)[]; RCVD_TLS_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:205.166.94.0/24]; MID_RHS_MATCH_FROM(0.00)[]; MIME_GOOD(-0.10)[text/plain]; NEURAL_HAM_LONG(-0.97)[-0.971]; TO_MATCH_ENVRCPT_SOME(0.00)[]; NEURAL_HAM_SHORT(-0.45)[-0.453]; RCPT_COUNT_TWO(0.00)[2]; DMARC_POLICY_ALLOW(-0.50)[sdf.org,quarantine]; NEURAL_HAM_MEDIUM(-1.01)[-1.011]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:14361, ipnet:205.166.94.0/24, country:US]; RCVD_COUNT_TWO(0.00)[2]; MAILMAN_DEST(0.00)[freebsd-questions] X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Oct 2020 04:24:31 -0000 On Tue, 29 Sep 2020 13:40:51 +0200 Polytropon wrote: >On Tue, 29 Sep 2020 06:42:18 -0400, Jerry wrote: >> I am trying to copy/move one file onto another. I need to preserve the >> creation date of the target file. I see options to preserve the >> creation date of the source file, but not the target file. Is it >> possible? > >THis is possible - it's important you do not unlink (remove) >the original file whose creation time you want to preserve. >I'm not sure if cp does this while overwriting, but you can >use shell redirection: > > $ cat /path/to/souce/file > /path/to/target/file > >Only the modification date will be altered. You can verify >that using "stat filename". > >Note that creation time refers to the inode. Even if you >re-create a file (remove, then create with the same name), >you'll probably get a different inode, and therefore a >different creation time. > >If you want to preserve modification and access time, you >can do so using "cp -p"; to alter them after creation, >use "touch -m" and "touch -a" respectively. > There exists another way that allows one to set the ctime. Offhand, I don't have any idea how to do it, but restore(8) certainly does. A "restore -rf /some/backupmadebydump/file" will restore an entire filesystem with each file's full set of timestamps intact. Recall that restore(8) rebuilds the filesystem by engaging the filesystem code, not by writing to a raw device. Any ideas what restore does to accomplish that? Scott Bennett, Comm. ASMELG, CFIAG ********************************************************************** * Internet: bennett at sdf.org *xor* bennett at freeshell.org * *--------------------------------------------------------------------* * "A well regulated and disciplined militia, is at all times a good * * objection to the introduction of that bane of all free governments * * -- a standing army." * * -- Gov. John Hancock, New York Journal, 28 January 1790 * **********************************************************************