From nobody Wed Aug 10 01:54:47 2022 X-Original-To: questions@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4M2Y0W43Qsz4YZX8 for ; Wed, 10 Aug 2022 01:54:51 +0000 (UTC) (envelope-from dpchrist@holgerdanske.com) Received: from holgerdanske.com (holgerdanske.com [IPv6:2001:470:0:19b::b869:801b]) (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 (4096 bits) client-digest SHA256) (Client CN "holgerdanske.com", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4M2Y0V2smCz43Vg for ; Wed, 10 Aug 2022 01:54:50 +0000 (UTC) (envelope-from dpchrist@holgerdanske.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=holgerdanske.com; s=nov-20210719-112354; t=1660096487; bh=W6CnZ5Hp0je6n3VtggHsbrIL7EfU+jJBmoeONZlCNQE=; h=Received:Message-ID:Date:MIME-Version:User-Agent:Subject: Content-Language:To:References:From:In-Reply-To:Content-Type: Content-Transfer-Encoding; b=fWA+uAs0QnZzMxKjGV6/dE/k+XQznYUGUQkbfUqIATyPYwK5FNitDVZRZcWSDsQyQ hITkO6Hwhpwqqg0PsYRwQhWkg9z00wO4vcgSOkg/tpmmRJLNiqrsHEi2i1pPByf8LW +xxXWM+50pa9ioKdADX+x7eFw/A3byXgnIWKAnLaChi3C7dr3nzInZHEjdwYmuhMvy PWt5lh0EhtsyxpwFnEwSypjjYwcBmq9ozgUr+2uEylXQJjgF4Rittpa854RkaZpiv0 qSDFO8kpzHUOYdLK0izC/aQhehVaJLtyALzqv1XSzWyaQpJ08tCApFJDf/BjbyZHlz 0+wyg951O3+t7vPZQgoNMkgHMLvdJp/7AIFtS2vSMtiDWDH88fi0Zaav9FXm7ZSFiH JH/KJYrnib40u+ZuqeoKfVFaZhY2ZmBhYeiaDGh3ufeSABD/ip9WgZONyxINHfXdhW OdSudVm6WoXIW4IXQ3Ng07DYwBM65Usk5f8Rd+tAmAAFOJ9Ao92bs0e/t7k1Zxe3q1 EvRanzIjH+VaaPSyKYO2c5qlpjqt/4UTEKOQXELcrqUuA15P+S2tCo5wU78IXIWB08 C2/Ex0jKKL84+GPX/d/75u7OFJlx135apBhCsilYivLg//hRuQnZllDr3JuOMupxBa jjRSz1oE6wvkSzsA+0ag0mYg= Received: from 99.100.19.101 (99-100-19-101.lightspeed.frokca.sbcglobal.net [99.100.19.101]) by holgerdanske.com with ESMTPSA (TLS_AES_128_GCM_SHA256:TLSv1.3:Kx=any:Au=any:Enc=AESGCM(128):Mac=AEAD) (SMTP-AUTH username dpchrist@holgerdanske.com, mechanism PLAIN) for ; Tue, 9 Aug 2022 18:54:47 -0700 Message-ID: <448ac676-5acd-02b2-00c6-5ae0c6773438@holgerdanske.com> Date: Tue, 9 Aug 2022 18:54:47 -0700 List-Id: User questions List-Archive: https://lists.freebsd.org/archives/freebsd-questions List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-questions@freebsd.org X-BeenThere: freebsd-questions@freebsd.org MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.12.0 Subject: Re: What is the best way to look for a lost file in the disk blocks Content-Language: en-US To: questions@freebsd.org References: <20220809122357.GA17@sh4-5.1blu.de> From: David Christensen In-Reply-To: <20220809122357.GA17@sh4-5.1blu.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 4M2Y0V2smCz43Vg X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=holgerdanske.com header.s=nov-20210719-112354 header.b=fWA+uAs0; dmarc=pass (policy=none) header.from=holgerdanske.com; spf=pass (mx1.freebsd.org: domain of dpchrist@holgerdanske.com designates 2001:470:0:19b::b869:801b as permitted sender) smtp.mailfrom=dpchrist@holgerdanske.com X-Spamd-Result: default: False [-4.00 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-1.00)[-1.000]; DMARC_POLICY_ALLOW(-0.50)[holgerdanske.com,none]; R_SPF_ALLOW(-0.20)[+a:november.he.net]; R_DKIM_ALLOW(-0.20)[holgerdanske.com:s=nov-20210719-112354]; MIME_GOOD(-0.10)[text/plain]; DKIM_TRACE(0.00)[holgerdanske.com:+]; ASN(0.00)[asn:6939, ipnet:2001:470::/32, country:US]; MLMMJ_DEST(0.00)[questions@freebsd.org]; MIME_TRACE(0.00)[0:+]; FROM_EQ_ENVFROM(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; TO_DN_NONE(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; ARC_NA(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FROM_HAS_DN(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[questions@freebsd.org]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_TLS_ALL(0.00)[] X-ThisMailContainsUnwantedMimeParts: N On 8/9/22 05:23, Matthias Apitz wrote: > > Hello, > > Last night I damaged a plain UTF-8 HTML file (I copied by accident a > JPEG file over it) and it turned out that the backup was done a month > ago. I learned my lesson from this re/ doing backups more often of files > I'm working on... > Maybe there is a chance that the disk blocks are still not overwritten, > what would be the best way to look for them block by block and if it > contains certain string "foo-bar" having the block number from the > beginning of the device to get it back with dd(1) into a file. Any > scripts or tools for this? You might be able to find raw blocks with grep(1) and/or Perl: https://unix.stackexchange.com/a/710673 But, I do not know how UFS chains together blocks to form a file. David p.s. If you put your development directory on ZFS, you can use zfs-auto-snapshot to take snapshots on whatever schedule you want.