From owner-freebsd-questions@freebsd.org Thu Oct 1 11:41:17 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 25021425D1C for ; Thu, 1 Oct 2020 11:41:17 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.17.24]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "mout.kundenserver.de", Issuer "TeleSec ServerPass Class 2 CA" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4C2B636HSzz41WD for ; Thu, 1 Oct 2020 11:41:15 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from r56.edvax.de ([94.222.7.144]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPA (Nemesis) id 1Mi23L-1ksM1Y2Zfd-00e32L for ; Thu, 01 Oct 2020 13:41:13 +0200 Date: Thu, 1 Oct 2020 13:41:13 +0200 From: Polytropon To: freebsd-questions@freebsd.org Subject: Re: Preserving target file's creation date Message-Id: <20201001134113.13ff6d86.freebsd@edvax.de> In-Reply-To: <20201001072728.000004b6@seibercom.net> References: <202010010424.0914OZ9Y029194@sdf.org> <20201001072728.000004b6@seibercom.net> Reply-To: Polytropon Organization: EDVAX X-Mailer: Sylpheed 3.1.1 (GTK+ 2.24.5; i386-portbld-freebsd8.2) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K1:PoYQYTNc6nBfi9fY9wzWiO8Mg4rOjNdS4O6ZqvqaSncOneAr6we MkccmsB2xkA7cWGWg6of3+11nf28J/LAD492Re6RlnkHoW+qq/hn/Ew1v83c/z1LXG5UqwP wtZZ1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 Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=none (mx1.freebsd.org: domain of freebsd@edvax.de has no SPF policy when checking 212.227.17.24) smtp.mailfrom=freebsd@edvax.de X-Spamd-Result: default: False [3.91 / 15.00]; HAS_REPLYTO(0.00)[freebsd@edvax.de]; RCVD_VIA_SMTP_AUTH(0.00)[]; MV_CASE(0.50)[]; TO_DN_NONE(0.00)[]; HAS_ORG_HEADER(0.00)[]; NEURAL_HAM_SHORT(-0.40)[-0.403]; RECEIVED_SPAMHAUS_PBL(0.00)[94.222.7.144:received]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; ASN(0.00)[asn:8560, ipnet:212.227.0.0/16, country:DE]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_LAST(0.00)[]; ARC_NA(0.00)[]; REPLYTO_EQ_FROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-questions@freebsd.org]; DMARC_NA(0.00)[edvax.de]; AUTH_NA(1.00)[]; RCPT_COUNT_ONE(0.00)[1]; NEURAL_SPAM_MEDIUM(1.02)[1.024]; NEURAL_SPAM_LONG(0.89)[0.890]; MID_CONTAINS_FROM(1.00)[]; RCVD_IN_DNSWL_NONE(0.00)[212.227.17.24:from]; R_SPF_NA(0.00)[no SPF record]; RWL_MAILSPIKE_POSSIBLE(0.00)[212.227.17.24:from]; 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 11:41:17 -0000 On Thu, 1 Oct 2020 07:27:28 -0400, Jerry wrote: > On Wed, 30 Sep 2020 23:24:35 -0500, Scott Bennett via freebsd-questions > commented: > > 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? > > > I found that 'touch -r ' works. It involves > slightly more work than I had intended, but it gets the job done. According to "man 1 touch", this does not change creation time: -r Use the access and modifications times from the specified file instead of the current time of day. It reads the access and modification timestamp from another file and applies those. Your initial question was about creation time, and that one will be written when the corresponding inode is being created, so the command mentioned above does _not_ affect creation date (while the "redirection trick" does). So if you want to keep all three timestamps identical, you'll have to combine both tasks. -- Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ...