Re: recover deleted file

2022-04-17 Thread Michael Gmelin



> On 17. Apr 2022, at 06:20, Peter Jeremy  wrote:
> 
> On 2022-Apr-17 01:13:02 +0300, Sami Halabi  wrote:
>> I understand its hard to undelete since no one designed UFS/ZFS to do so..
>> that why I asked in later replies to see if someone would step in and
>> implement such a "feature" and I suggested some directions/thoughts.
> 
> As you point out, neither UFS nor ZFS were designed to support an
> "undelete" function: Once an inode has no references (open files
> or directory entries), the inode and all associated data blocks are
> returned to the free list and could be used by a subsequent allocation.
> 
> What semantics would you like UFS or ZFS to implement instead?  Is it
> just that the inode and associated data blocks should stay in limbo
> for some period?  If, what controls the period?  What if a file is
> truncated to 0 or overwritten before being unlinked?  How much would
> you be willing to pay for "undelete" functionality?
> 
>> As soren@ suggested in later reply it maybe would be easier to implement
>> custom rm script that moves files to "Recycle bin" directory (and empty it
>> after some period)
> 
> Alternatively, you could alias "rm" to "rm -i".
> 
>> but as a programmer I know that perfection is needed :)
>> so It might start as a simple task and end in many what-if's
>> (unfortunattly I did my last C programming in late 2003!).
> 
> This doesn't need to be C.  You could do this in your scripting
> language of choice.  Or you could offer to pay someone to do this
> for you.
> 
>> What amzes me is that this "feature" was asked too much in the last decade
>> or two and no one ever implemented it, maybe it's not needed in daily
>> usage, but in disasters it would be super userful, save admins many time
>> and nerves..
> 
> I went rummaging back through my mail archives and it actually doesn't
> seem to come up that often.  You seem to be about the 3rd person this
> century on the lists I read.  I did find a discussion in zfs-discuss
> from May/June 2006 about supporting undelete but it seems that no
> agreement on the desired behaviour was achieved.
> 
>> For now I did some backup tools locally and used chflags to mark them
>> undeletable so I wouldn't do that mistake again,
> 
> You could also consider snapshots - both UFS and ZFS support snapshots.
> 
> If the information is very critical (you mentioned legal consequences)
> then you might like to consider real-time replication of the MySQL redo
> logs to another systems - though that won't necessarily protect you
> from someone accidently doing a "DELETE FROM xxx;" or "DROP TABLE xxx;

It will, if you keep the binary logs/replication logs around. Combined with 
regular zfs snapshots (on the replicant‘s side) you can do a robust and 
relatively speedy point in time recovery that prevents data loss (ideally, 
access to the main db and the replicant is segregated). Saved me more than once.

Best
Michael





Re: recover deleted file

2022-04-17 Thread Piotr P. Stefaniak

On 2022-04-17 14:13:07, Peter Jeremy wrote:

If the information is very critical (you mentioned legal consequences)
then you might like to consider real-time replication of the MySQL redo
logs to another systems - though that won't necessarily protect you
from someone accidently doing a "DELETE FROM xxx;" or "DROP TABLE xxx;"


It won't, but if it's a delayed replica, you have some time to recover
the data.

Piotr



Re: recover deleted file

2022-04-16 Thread Peter Jeremy
On 2022-Apr-17 01:13:02 +0300, Sami Halabi  wrote:
>I understand its hard to undelete since no one designed UFS/ZFS to do so..
>that why I asked in later replies to see if someone would step in and
>implement such a "feature" and I suggested some directions/thoughts.

As you point out, neither UFS nor ZFS were designed to support an
"undelete" function: Once an inode has no references (open files
or directory entries), the inode and all associated data blocks are
returned to the free list and could be used by a subsequent allocation.

What semantics would you like UFS or ZFS to implement instead?  Is it
just that the inode and associated data blocks should stay in limbo
for some period?  If, what controls the period?  What if a file is
truncated to 0 or overwritten before being unlinked?  How much would
you be willing to pay for "undelete" functionality?

>As soren@ suggested in later reply it maybe would be easier to implement
>custom rm script that moves files to "Recycle bin" directory (and empty it
>after some period)

Alternatively, you could alias "rm" to "rm -i".

>but as a programmer I know that perfection is needed :)
>so It might start as a simple task and end in many what-if's
>(unfortunattly I did my last C programming in late 2003!).

This doesn't need to be C.  You could do this in your scripting
language of choice.  Or you could offer to pay someone to do this
for you.

>What amzes me is that this "feature" was asked too much in the last decade
>or two and no one ever implemented it, maybe it's not needed in daily
>usage, but in disasters it would be super userful, save admins many time
>and nerves..

I went rummaging back through my mail archives and it actually doesn't
seem to come up that often.  You seem to be about the 3rd person this
century on the lists I read.  I did find a discussion in zfs-discuss
from May/June 2006 about supporting undelete but it seems that no
agreement on the desired behaviour was achieved.

>For now I did some backup tools locally and used chflags to mark them
>undeletable so I wouldn't do that mistake again,

You could also consider snapshots - both UFS and ZFS support snapshots.

If the information is very critical (you mentioned legal consequences)
then you might like to consider real-time replication of the MySQL redo
logs to another systems - though that won't necessarily protect you
from someone accidently doing a "DELETE FROM xxx;" or "DROP TABLE xxx;"

-- 
Peter Jeremy


signature.asc
Description: PGP signature


Re: recover deleted file

2022-04-16 Thread Jamie Landeg-Jones
Sami Halabi  wrote:

> Hi,
> thanks for your response.
>
> Would someone from the foundation step in and put it in GSOC ideas?
>
> kirk@ - would it be possible for you to do it ? :)
>
How would you handle file modifications? Backup every original too, or
just deal with literal deletions?

If you are just concerned with user accidental deletions, you can easily
modify your view of "rm" to point to something that instead stores the
file somewhere safe..

Jamie



Re: recover deleted file

2022-04-16 Thread Sami Halabi
Hi warner,
Thanks for trying :)

Actually my use case was (if you read later replies, i gave up since the
downtime was too long and couldn't wait more) a VM in ESXi.
so all the underlying stuff of the disks/TRIM.. is hidden an
inaccessible for me (hosting provider).

In my case I tried to recover MariaDB database files, and some tar.gz file
of backups of the db that I accidentally deleted all together (mysql*
instead of mysql/*  , my bad, deleted mysql/ & mysql_backups!!). I stopped
all services immediately, so maybe I would succeed if I wasn't time limited.

I understand its hard to undelete since no one designed UFS/ZFS to do so..
that why I asked in later replies to see if someone would step in and
implement such a "feature" and I suggested some directions/thoughts.

As soren@ suggested in later reply it maybe would be easier to implement
custom rm script that moves files to "Recycle bin" directory (and empty it
after some period) but as a programmer I know that perfection is needed :)
so It might start as a simple task and end in many what-if's
(unfortunattly I did my last C programming in late 2003!).

What amzes me is that this "feature" was asked too much in the last decade
or two and no one ever implemented it, maybe it's not needed in daily
usage, but in disasters it would be super userful, save admins many time
and nerves..

For now I did some backup tools locally and used chflags to mark them
undeletable so I wouldn't do that mistake again, plus I rsync them to my
home storage.. so probably I would be more resilent to such mistakes in the
future.. but the same problem remains.. accidently deleted
file(s)/directory(s) are the nightmare of all admins in earth!!

Sami

On Sun, Apr 17, 2022 at 12:42 AM Warner Losh  wrote:

>
>
> On Sat, Apr 16, 2022 at 5:24 AM Sami Halabi  wrote:
>
>> Hi,
>> is there anyway easy to restore deleted file by accident in UFS
>>
>
> Do you know what the contents of the file is? At least the first, say,
> ~32k?
>
> The problem with unrm for ufs is that the directory entry has the inode
> number stored in it.
> Without the inode number, you won't get very far.
> With the inode number, you can get the first 12 filesystem blocks of the
> file and the
> first three indirect blocks. Once you have those, you can reconstruct the
> file.
>
> But only if the inode hasn't been zero'd out (which it likely has, another
> thing that makes
> UFS undelete harder). But all hope isn't lost...  UFS has a predictable
> allocation algorithm
> that lets you get much of the file back (which is why I asked if you know
> how it should start:
> you can find where it starts in the data blocks and maybe get lucky with
> the rest if the
> data spills into indirect blocks).
>
> However, that's only if you don't have TRIM enabled on the filesystem. If
> you do,
> then UFS will do a BIO_DELETE of the blocks, which means their contents are
> likely gone at the drive level. I say likely because there's weasel words
> in the ATA
> spec that allows a drive to return the prior contents of the blocks, or
> all zeros or
> the drive's initialization pattern (usually all 1's) when the blocks are
> later read. Same
> goes for NVMe drives (with the additional constraint it must be
> deterministic). So there's
> may still be a chance you can read the old contents, but drives that do
> that are rare
> in my experience (which is admittedly quite narrow).
>
> But, if you want to use fsdb to try to recover this data, or write your
> own tools,
> then you should likely have a copy of the daemon book (The Design and
> Implementation
> of the FreeBSD Operating System). It explains a lot of the finer details
> of UFS and
> reference to it likely will catch me where my memory isn't quite right in
> the above
> descriptions.
>
> So, it's for all these reasons you can't find somebody with a unrm command
> for ufs
> like you can for DOS or other filesystems. I wish I had a better answer
> for you.
>
> Warner
>
>
>> Sami
>>
>> --
>> Sami Halabi
>> Information Systems Engineer
>> NMS Projects Expert, FreeBSD SysAdmin Expert
>> Asterisk Expert
>>
>

-- 
Sami Halabi
Information Systems Engineer
NMS Projects Expert, FreeBSD SysAdmin Expert
Asterisk Expert


Re: recover deleted file

2022-04-16 Thread Warner Losh
On Sat, Apr 16, 2022 at 5:24 AM Sami Halabi  wrote:

> Hi,
> is there anyway easy to restore deleted file by accident in UFS
>

Do you know what the contents of the file is? At least the first, say, ~32k?

The problem with unrm for ufs is that the directory entry has the inode
number stored in it.
Without the inode number, you won't get very far.
With the inode number, you can get the first 12 filesystem blocks of the
file and the
first three indirect blocks. Once you have those, you can reconstruct the
file.

But only if the inode hasn't been zero'd out (which it likely has, another
thing that makes
UFS undelete harder). But all hope isn't lost...  UFS has a predictable
allocation algorithm
that lets you get much of the file back (which is why I asked if you know
how it should start:
you can find where it starts in the data blocks and maybe get lucky with
the rest if the
data spills into indirect blocks).

However, that's only if you don't have TRIM enabled on the filesystem. If
you do,
then UFS will do a BIO_DELETE of the blocks, which means their contents are
likely gone at the drive level. I say likely because there's weasel words
in the ATA
spec that allows a drive to return the prior contents of the blocks, or all
zeros or
the drive's initialization pattern (usually all 1's) when the blocks are
later read. Same
goes for NVMe drives (with the additional constraint it must be
deterministic). So there's
may still be a chance you can read the old contents, but drives that do
that are rare
in my experience (which is admittedly quite narrow).

But, if you want to use fsdb to try to recover this data, or write your own
tools,
then you should likely have a copy of the daemon book (The Design and
Implementation
of the FreeBSD Operating System). It explains a lot of the finer details of
UFS and
reference to it likely will catch me where my memory isn't quite right in
the above
descriptions.

So, it's for all these reasons you can't find somebody with a unrm command
for ufs
like you can for DOS or other filesystems. I wish I had a better answer for
you.

Warner


> Sami
>
> --
> Sami Halabi
> Information Systems Engineer
> NMS Projects Expert, FreeBSD SysAdmin Expert
> Asterisk Expert
>


Re: recover deleted file

2022-04-16 Thread Søren Schmidt
Just replace rm with a script that moves files to a trash folder, then either 
clean that automagically after some period of time or handle it manually.
Doesn’t have to be complicated…

-Søren


> On 16 Apr 2022, at 21.08, Weldon Godfrey  wrote:
> 
> 
> 
>> On Apr 16, 2022, at 12:27 PM, Julian H. Stacey  wrote:
>> 
>> 
>>> 
>>> okay...
>>> all seems very time consuming operations!!
>> 
>> Yes
>> 
>>> There should be an os "undelete" as happens in NTFS for example.. which is
>>> very fast and can be done also with extra tools without a hassle.
>> 
>> A WIBNI (Wouldnt It Be Nice If) for Unix FS's for as long as I can remember
>> (decades) but no one's ever done it. 
>> 
>> Ways to get it done:
>> Get it listed as a Google Summer Of Code project for FreeBSD, Or
>> 
>> Get your employer to help pay for it, eg chip in with other BSD
>> user companies to pay some money to FreeBSD Foundation, & get
>> them to pay for it to be developed.
>> 
>> Or hire are an individual freelance BSD Consultant to do it,
>>   There's a global index here http://berklix.com/consultants/
>> 
>> & a mail list that's moderated jobs@freebsd
>> 
>> Some author(s) of BSD FFS are on list fs@, Kirk is one name springs
>> to mind ? Some freelancers on fs@ I recall.
>> 
>> IMO Would be a fun job if funded :-)
>> 
>>> 
>>> for now I got backup from last day .. caused me a lot of troubles, not say
>>> legal ones, but I passed the point to hold the machine down.
>>> 
>>> any advice?
>>> 
>>> Maybe UFS developer would do a rework so latest deleted inodes would put in
>>> a "recycle bin" (maybe with a sysctl or whatever) for say one day (or any
>>> other configurable sysctl) and allow to recover quickly or "force delete /
>>> empty recycle bin" , rather than delete and give back space immediately for
>>> use and destroy possibility to restore.
>>> 
>>> my 2 cents.
>>> 
>>> Sami
>> 
>> 
> 
> or just use ZFS filesystem and leverage regular snapshots.   I wrote a script 
> that manages snapshots (moves to weekly, monthly and deletes snaps) but i 
> believe there is a utility in the ports collection that will do the automated 
> management. 
> 
> 
>> 
> 



Re: recover deleted file

2022-04-16 Thread Weldon Godfrey



> On Apr 16, 2022, at 12:27 PM, Julian H. Stacey  wrote:
> 
> 
>> 
>> okay...
>> all seems very time consuming operations!!
> 
> Yes
> 
>> There should be an os "undelete" as happens in NTFS for example.. which is
>> very fast and can be done also with extra tools without a hassle.
> 
> A WIBNI (Wouldnt It Be Nice If) for Unix FS's for as long as I can remember
> (decades) but no one's ever done it. 
> 
> Ways to get it done:
>  Get it listed as a Google Summer Of Code project for FreeBSD, Or
> 
>  Get your employer to help pay for it, eg chip in with other BSD
>  user companies to pay some money to FreeBSD Foundation, & get
>  them to pay for it to be developed.
> 
>  Or hire are an individual freelance BSD Consultant to do it,
>There's a global index here http://berklix.com/consultants/
> 
>  & a mail list that's moderated jobs@freebsd
> 
>  Some author(s) of BSD FFS are on list fs@, Kirk is one name springs
>  to mind ? Some freelancers on fs@ I recall.
> 
>  IMO Would be a fun job if funded :-)
> 
>> 
>> for now I got backup from last day .. caused me a lot of troubles, not say
>> legal ones, but I passed the point to hold the machine down.
>> 
>> any advice?
>> 
>> Maybe UFS developer would do a rework so latest deleted inodes would put in
>> a "recycle bin" (maybe with a sysctl or whatever) for say one day (or any
>> other configurable sysctl) and allow to recover quickly or "force delete /
>> empty recycle bin" , rather than delete and give back space immediately for
>> use and destroy possibility to restore.
>> 
>> my 2 cents.
>> 
>> Sami
> 
> 

or just use ZFS filesystem and leverage regular snapshots.   I wrote a script 
that manages snapshots (moves to weekly, monthly and deletes snaps) but i 
believe there is a utility in the ports collection that will do the automated 
management. 


> 



Re: recover deleted file

2022-04-16 Thread Kyle Evans
On Sat, Apr 16, 2022 at 12:36 PM Sami Halabi  wrote:
>
> Hi,
> thanks for your response.
>
> Would someone from the foundation step in and put it in GSOC ideas?
>
> kirk@ - would it be possible for you to do it ? :)
>

Anyone with wiki access is able to add ideas, any student eligible for
GSoC is able to propose ideas (regardless of whether we've pitched the
ideas on our wiki or not).

Thanks,

Kyle Evans

>
> On Sat, Apr 16, 2022 at 7:26 PM Julian H. Stacey  wrote:
>>
>> > okay...
>> > all seems very time consuming operations!!
>>
>> Yes
>>
>> > There should be an os "undelete" as happens in NTFS for example.. which is
>> > very fast and can be done also with extra tools without a hassle.
>>
>> A WIBNI (Wouldnt It Be Nice If) for Unix FS's for as long as I can remember
>> (decades) but no one's ever done it.
>>
>> Ways to get it done:
>>   Get it listed as a Google Summer Of Code project for FreeBSD, Or
>>
>>   Get your employer to help pay for it, eg chip in with other BSD
>>   user companies to pay some money to FreeBSD Foundation, & get
>>   them to pay for it to be developed.
>>
>>   Or hire are an individual freelance BSD Consultant to do it,
>> There's a global index here http://berklix.com/consultants/
>>
>>   & a mail list that's moderated jobs@freebsd
>>
>>   Some author(s) of BSD FFS are on list fs@, Kirk is one name springs
>>   to mind ? Some freelancers on fs@ I recall.
>>
>>   IMO Would be a fun job if funded :-)
>>
>> >
>> > for now I got backup from last day .. caused me a lot of troubles, not say
>> > legal ones, but I passed the point to hold the machine down.
>> >
>> > any advice?
>> >
>> > Maybe UFS developer would do a rework so latest deleted inodes would put in
>> > a "recycle bin" (maybe with a sysctl or whatever) for say one day (or any
>> > other configurable sysctl) and allow to recover quickly or "force delete /
>> > empty recycle bin" , rather than delete and give back space immediately for
>> > use and destroy possibility to restore.
>> >
>> > my 2 cents.
>> >
>> > Sami
>>
>> Cheers,
>> --
>> Julian Stacey  http://berklix.com/jhs/ http://StolenVotes.UK
>> Kill / remove Putin to stop him killing & provoking world war.
>
>
>
> --
> Sami Halabi
> Information Systems Engineer
> NMS Projects Expert, FreeBSD SysAdmin Expert
> Asterisk Expert



Re: recover deleted file

2022-04-16 Thread Sami Halabi
Hi,
thanks for your response.

Would someone from the foundation step in and put it in GSOC ideas?

kirk@ - would it be possible for you to do it ? :)

Sami


On Sat, Apr 16, 2022 at 7:26 PM Julian H. Stacey  wrote:

> > okay...
> > all seems very time consuming operations!!
>
> Yes
>
> > There should be an os "undelete" as happens in NTFS for example.. which
> is
> > very fast and can be done also with extra tools without a hassle.
>
> A WIBNI (Wouldnt It Be Nice If) for Unix FS's for as long as I can remember
> (decades) but no one's ever done it.
>
> Ways to get it done:
>   Get it listed as a Google Summer Of Code project for FreeBSD, Or
>
>   Get your employer to help pay for it, eg chip in with other BSD
>   user companies to pay some money to FreeBSD Foundation, & get
>   them to pay for it to be developed.
>
>   Or hire are an individual freelance BSD Consultant to do it,
> There's a global index here http://berklix.com/consultants/
>
>   & a mail list that's moderated jobs@freebsd
>
>   Some author(s) of BSD FFS are on list fs@, Kirk is one name springs
>   to mind ? Some freelancers on fs@ I recall.
>
>   IMO Would be a fun job if funded :-)
>
> >
> > for now I got backup from last day .. caused me a lot of troubles, not
> say
> > legal ones, but I passed the point to hold the machine down.
> >
> > any advice?
> >
> > Maybe UFS developer would do a rework so latest deleted inodes would put
> in
> > a "recycle bin" (maybe with a sysctl or whatever) for say one day (or any
> > other configurable sysctl) and allow to recover quickly or "force delete
> /
> > empty recycle bin" , rather than delete and give back space immediately
> for
> > use and destroy possibility to restore.
> >
> > my 2 cents.
> >
> > Sami
>
> Cheers,
> --
> Julian Stacey  http://berklix.com/jhs/ http://StolenVotes.UK
> Kill / remove Putin to stop him killing & provoking world war.
>


-- 
Sami Halabi
Information Systems Engineer
NMS Projects Expert, FreeBSD SysAdmin Expert
Asterisk Expert


Re: recover deleted file

2022-04-16 Thread olli hauer

Hi,
is there anyway easy to restore deleted file by accident in UFS


depends, years ago i had to use sysutils/testdisk to restore files from UFS 
after a HD crash.

Using the tools was easy but finding the right data in all the files the tool 
restored can be time consuming.

--
Good luck
olli





Re: recover deleted file

2022-04-16 Thread Julian H. Stacey
> okay...
> all seems very time consuming operations!!

Yes

> There should be an os "undelete" as happens in NTFS for example.. which is
> very fast and can be done also with extra tools without a hassle.

A WIBNI (Wouldnt It Be Nice If) for Unix FS's for as long as I can remember
(decades) but no one's ever done it. 

Ways to get it done:
  Get it listed as a Google Summer Of Code project for FreeBSD, Or

  Get your employer to help pay for it, eg chip in with other BSD
  user companies to pay some money to FreeBSD Foundation, & get
  them to pay for it to be developed.

  Or hire are an individual freelance BSD Consultant to do it,
There's a global index here http://berklix.com/consultants/

  & a mail list that's moderated jobs@freebsd

  Some author(s) of BSD FFS are on list fs@, Kirk is one name springs
  to mind ? Some freelancers on fs@ I recall.

  IMO Would be a fun job if funded :-)

> 
> for now I got backup from last day .. caused me a lot of troubles, not say
> legal ones, but I passed the point to hold the machine down.
> 
> any advice?
> 
> Maybe UFS developer would do a rework so latest deleted inodes would put in
> a "recycle bin" (maybe with a sysctl or whatever) for say one day (or any
> other configurable sysctl) and allow to recover quickly or "force delete /
> empty recycle bin" , rather than delete and give back space immediately for
> use and destroy possibility to restore.
> 
> my 2 cents.
> 
> Sami

Cheers,
-- 
Julian Stacey  http://berklix.com/jhs/ http://StolenVotes.UK  
Kill / remove Putin to stop him killing & provoking world war.



Re: recover deleted file

2022-04-16 Thread Bakul Shah
This may help? I’ve no experience with it, I just googled it for you. The 
comp.sources.misc usenet group in volume 17 issue 23 (in 1991) has an undelete 
program that supposedly works with 4.3BSD — probably won’t work with FreeBSD’s 
version but if you’re desperate it could be a starting point.
https://www.ufsexplorer.com/solutions/recover-deleted-files-bsd.php

Since you asked for advice, this may just be the nature’s way of telling you 
you really didn’t need the file. It can be a very “free”ing experience :-)

> On Apr 16, 2022, at 8:03 AM, Sami Halabi  wrote:
> 
> 
> okay...
> all seems very time consuming operations!!
> 
> There should be an os "undelete" as happens in NTFS for example.. which is 
> very fast and can be done also with extra tools without a hassle.
> 
> for now I got backup from last day .. caused me a lot of troubles, not say 
> legal ones, but I passed the point to hold the machine down.
> 
> any advice?
> 
> Maybe UFS developer would do a rework so latest deleted inodes would put in a 
> "recycle bin" (maybe with a sysctl or whatever) for say one day (or any other 
> configurable sysctl) and allow to recover quickly or "force delete / empty 
> recycle bin" , rather than delete and give back space immediately for use and 
> destroy possibility to restore.
> 
> my 2 cents.
> 
> Sami
> 
> 
> 
>> On Sat, Apr 16, 2022 at 5:23 PM Julian H. Stacey  wrote:
>> > Then I would reboot single user, 
>> > fsck & mount only the partitions the data was Not on.,
>> > dd the partition to recover,
>> > then fsck the partition & mount it, & go multi user,
>> > then I'd make a 2nd copy of the partition with data to recover
>> 
>> Oops. I meant:
>> 
>> .. I'd make a 2nd copy (with cp) from the 1st image file,
>>not of course Not a copy of raw decice partition after fsck
>>has discarded blocks.
>> 
>> The spare 2nd. copy because I've zapped data too often, trying to rescue
>> it, while fumbling with unfamiliar resue tools: its easier to
>> have a play image one can experimentaly try to recover from, &
>> periodicaly while one learns, & that gets in a mess,  one can refresh
>> copy from master to experimental copy.
>> 
>> If any recovery tools want to run on devices, & refuse images in files, use
>> mdconfig -a -t vnode -f imagefile
>> 
>> I recall FS has journals etc, 
>> Specalists on list fs@
>> 
>> Cheers,
>> -- 
>> Julian Stacey  http://berklix.com/jhs/ http://StolenVotes.UK  
>> Kill / remove Putin to stop him killing & provoking world war.
> 
> 
> -- 
> Sami Halabi
> Information Systems Engineer
> NMS Projects Expert, FreeBSD SysAdmin Expert
> Asterisk Expert


Re: recover deleted file

2022-04-16 Thread Kurt Jaeger
Hi!

> Maybe UFS developer would do a rework so latest deleted inodes would put in
> a "recycle bin"

Use ZFS and snapshots, that should help your use-case.

-- 
p...@opsec.eu+49 171 3101372Now what ?



Re: recover deleted file

2022-04-16 Thread Sami Halabi
okay...
all seems very time consuming operations!!

There should be an os "undelete" as happens in NTFS for example.. which is
very fast and can be done also with extra tools without a hassle.

for now I got backup from last day .. caused me a lot of troubles, not say
legal ones, but I passed the point to hold the machine down.

any advice?

Maybe UFS developer would do a rework so latest deleted inodes would put in
a "recycle bin" (maybe with a sysctl or whatever) for say one day (or any
other configurable sysctl) and allow to recover quickly or "force delete /
empty recycle bin" , rather than delete and give back space immediately for
use and destroy possibility to restore.

my 2 cents.

Sami



On Sat, Apr 16, 2022 at 5:23 PM Julian H. Stacey  wrote:

> > Then I would reboot single user,
> > fsck & mount only the partitions the data was Not on.,
> > dd the partition to recover,
> > then fsck the partition & mount it, & go multi user,
> > then I'd make a 2nd copy of the partition with data to recover
>
> Oops. I meant:
>
> .. I'd make a 2nd copy (with cp) from the 1st image file,
>not of course Not a copy of raw decice partition after fsck
>has discarded blocks.
>
> The spare 2nd. copy because I've zapped data too often, trying to rescue
> it, while fumbling with unfamiliar resue tools: its easier to
> have a play image one can experimentaly try to recover from, &
> periodicaly while one learns, & that gets in a mess,  one can refresh
> copy from master to experimental copy.
>
> If any recovery tools want to run on devices, & refuse images in files, use
> mdconfig -a -t vnode -f imagefile
>
> I recall FS has journals etc,
> Specalists on list fs@
>
> Cheers,
> --
> Julian Stacey  http://berklix.com/jhs/ http://StolenVotes.UK
> Kill / remove Putin to stop him killing & provoking world war.
>


-- 
Sami Halabi
Information Systems Engineer
NMS Projects Expert, FreeBSD SysAdmin Expert
Asterisk Expert


Re: recover deleted file

2022-04-16 Thread Julian H. Stacey
> Depends on the kind of file.
> 
> You can always:
> 1. reboot the system into single user mode, mount the fs readonly (important=
>  to not overwrite data you want to recover)
> 2. dd the partition and into a file
> 3. find the content of the deleted file in the dump
> 
> I was able to recover a complete codebase i deleted accidentally that way a l=
> ong time ago.
> 
> Good luck
> Michael

If it was my personal laptop with an external disk/ stick,
I would _immediately_ pull the USB cable out.
If a personal PC I would _immediately_ turn power off.
I would Not do an unmount or sync or processes kill or shutdown.

Then I would reboot single user, 
fsck & mount only the partitions the data was Not on.,
dd the partition to recover,
then fsck the partition & mount it, & go multi user,
then I'd make a 2nd copy of the partition with data to recover
& start exploration with eg fsdb
man fsdb:
SEE ALSO
   editline(3), fs(5), clri(8), fsck(8), /usr/ports/ { graphics/recoverjpeg,
 sysutils/ { autopsy, dd_rescue, ddrescue, fatback, ffs2recov, foremost,
 gpart, magicrescue, recoverdm, scan_ffs, sleuthkit, testdisk } }.

If you work had been on text using vi, then vi -r might show a recovery,
hint copy the original before running vi -r file , as sometimes pre recovery
is better than after.

various lost+found may have stuff in
http://berklix.com/~jhs/bin/.sh/lslf

PS personaly I hand run numerous rdist6 or rsync through the day,
when editing important stuff. They run fast, as incremental update,
so avoid losing all but the last short period in a day.

Cheers,
-- 
Julian Stacey  http://berklix.com/jhs/ http://StolenVotes.UK  
Kill / remove Putin to stop him killing & provoking world war.



Re: recover deleted file

2022-04-16 Thread Michael Gmelin


> On 16. Apr 2022, at 14:32, Sami Halabi  wrote:
> 
> 
> how to do step 3 /?

E.g., grep for something you know (like a phrase, unique name etc) from the 
file, then dump N times the expected file size from that position into another 
file, open the result in a “robust” text editor and stitch things together.

If your lost file is something binary (or even worse, encrypted), things get a 
lot more complicated of course. There might be tooling for this I’m not aware 
of, the few times this happened to me, lost files where C++ sources that were 
relatively easy to extract manually.

Best
Michael

> 
>> On Sat, Apr 16, 2022 at 2:59 PM Michael Gmelin  wrote:
>> Depends on the kind of file.
>> 
>> You can always:
>> 1. reboot the system into single user mode, mount the fs readonly (important 
>> to not overwrite data you want to recover)
>> 2. dd the partition and into a file
>> 3. find the content of the deleted file in the dump
>> 
>> I was able to recover a complete codebase i deleted accidentally that way a 
>> long time ago.
>> 
>> Good luck
>> Michael
>> 
 On 16. Apr 2022, at 13:52, Sami Halabi  wrote:
 
>>> 
>>> well.. thats the trivial answer.. the problem is backups is a day before... 
>>> if i can undelete it would save me loss of 1 day offset..
>>> 
>>> anyone?
>>> 
 On Sat, Apr 16, 2022 at 2:49 PM Matthias Apitz  wrote:
 El día sábado, abril 16, 2022 a las 02:23:25 +0300, Sami Halabi escribió:
 
 > Hi,
 > is there anyway easy to restore deleted file by accident in UFS
 
 Yes, restore it from a backup media.
 
 matthias
 
 
 -- 
 Matthias Apitz, ✉ g...@unixarea.de, http://www.unixarea.de/ 
 +49-176-38902045
 Public GnuPG key: http://www.unixarea.de/key.pub
 
 Peace instead of NATO!  Мир вместо НАТО!  Frieden statt NATO! ¡Paz en vez 
 de OTAN!
 
>>> 
>>> 
>>> -- 
>>> Sami Halabi
>>> Information Systems Engineer
>>> NMS Projects Expert, FreeBSD SysAdmin Expert
>>> Asterisk Expert
> 
> 
> -- 
> Sami Halabi
> Information Systems Engineer
> NMS Projects Expert, FreeBSD SysAdmin Expert
> Asterisk Expert


Re: recover deleted file

2022-04-16 Thread Alexandre Biancalana
On Sat, 16 Apr 2022 at 09:33 Sami Halabi  wrote:

> how to do step 3 /?
>
> On Sat, Apr 16, 2022 at 2:59 PM Michael Gmelin  wrote:
>
>> Depends on the kind of file.
>>
>> You can always:
>> 1. reboot the system into single user mode, mount the fs readonly
>> (important to not overwrite data you want to recover)
>> 2. dd the partition and into a file
>> 3. find the content of the deleted file in the dump
>>
>> I was able to recover a complete codebase i deleted accidentally that way
>> a long time ago.
>>
>> Good luck
>> Michael
>>
>> On 16. Apr 2022, at 13:52, Sami Halabi  wrote:
>>
>> 
>> well.. thats the trivial answer.. the problem is backups is a day
>> before... if i can undelete it would save me loss of 1 day offset..
>>
>> anyone?
>>
>> On Sat, Apr 16, 2022 at 2:49 PM Matthias Apitz  wrote:
>>
>>> El día sábado, abril 16, 2022 a las 02:23:25 +0300, Sami Halabi escribió:
>>>
>>> > Hi,
>>> > is there anyway easy to restore deleted file by accident in UFS
>>>
>>> Yes, restore it from a backup media.
>>>
>>> matthias
>>>
>>>
>>> --
>>> Matthias Apitz, ✉ g...@unixarea.de, http://www.unixarea.de/
>>> +49-176-38902045
>>> Public GnuPG key: http://www.unixarea.de/key.pub
>>>
>>> Peace instead of NATO!  Мир вместо НАТО!  Frieden statt NATO! ¡Paz en
>>> vez de OTAN!
>>>
>>>
>>
>> --
>> Sami Halabi
>> Information Systems Engineer
>> NMS Projects Expert, FreeBSD SysAdmin Expert
>> Asterisk Expert
>>
>>
>
> --
> Sami Halabi
> Information Systems Engineer
> NMS Projects Expert, FreeBSD SysAdmin Expert
> Asterisk Expert
>

Look at autopsy/photorec

https://www.cgsecurity.org/wiki/PhotoRec_Data_Carving


Re: recover deleted file

2022-04-16 Thread Sami Halabi
how to do step 3 /?

On Sat, Apr 16, 2022 at 2:59 PM Michael Gmelin  wrote:

> Depends on the kind of file.
>
> You can always:
> 1. reboot the system into single user mode, mount the fs readonly
> (important to not overwrite data you want to recover)
> 2. dd the partition and into a file
> 3. find the content of the deleted file in the dump
>
> I was able to recover a complete codebase i deleted accidentally that way
> a long time ago.
>
> Good luck
> Michael
>
> On 16. Apr 2022, at 13:52, Sami Halabi  wrote:
>
> 
> well.. thats the trivial answer.. the problem is backups is a day
> before... if i can undelete it would save me loss of 1 day offset..
>
> anyone?
>
> On Sat, Apr 16, 2022 at 2:49 PM Matthias Apitz  wrote:
>
>> El día sábado, abril 16, 2022 a las 02:23:25 +0300, Sami Halabi escribió:
>>
>> > Hi,
>> > is there anyway easy to restore deleted file by accident in UFS
>>
>> Yes, restore it from a backup media.
>>
>> matthias
>>
>>
>> --
>> Matthias Apitz, ✉ g...@unixarea.de, http://www.unixarea.de/
>> +49-176-38902045
>> Public GnuPG key: http://www.unixarea.de/key.pub
>>
>> Peace instead of NATO!  Мир вместо НАТО!  Frieden statt NATO! ¡Paz en vez
>> de OTAN!
>>
>>
>
> --
> Sami Halabi
> Information Systems Engineer
> NMS Projects Expert, FreeBSD SysAdmin Expert
> Asterisk Expert
>
>

-- 
Sami Halabi
Information Systems Engineer
NMS Projects Expert, FreeBSD SysAdmin Expert
Asterisk Expert


Re: recover deleted file

2022-04-16 Thread Michael Gmelin
Depends on the kind of file.

You can always:
1. reboot the system into single user mode, mount the fs readonly (important to 
not overwrite data you want to recover)
2. dd the partition and into a file
3. find the content of the deleted file in the dump

I was able to recover a complete codebase i deleted accidentally that way a 
long time ago.

Good luck
Michael

> On 16. Apr 2022, at 13:52, Sami Halabi  wrote:
> 
> 
> well.. thats the trivial answer.. the problem is backups is a day before... 
> if i can undelete it would save me loss of 1 day offset..
> 
> anyone?
> 
>> On Sat, Apr 16, 2022 at 2:49 PM Matthias Apitz  wrote:
>> El día sábado, abril 16, 2022 a las 02:23:25 +0300, Sami Halabi escribió:
>> 
>> > Hi,
>> > is there anyway easy to restore deleted file by accident in UFS
>> 
>> Yes, restore it from a backup media.
>> 
>> matthias
>> 
>> 
>> -- 
>> Matthias Apitz, ✉ g...@unixarea.de, http://www.unixarea.de/ +49-176-38902045
>> Public GnuPG key: http://www.unixarea.de/key.pub
>> 
>> Peace instead of NATO!  Мир вместо НАТО!  Frieden statt NATO! ¡Paz en vez de 
>> OTAN!
>> 
> 
> 
> -- 
> Sami Halabi
> Information Systems Engineer
> NMS Projects Expert, FreeBSD SysAdmin Expert
> Asterisk Expert


Re: recover deleted file

2022-04-16 Thread Michael Schuster
On Sat, Apr 16, 2022, 13:24 Sami Halabi  wrote:

> Hi,
> is there anyway easy to restore deleted file by accident in UFS
>

If you used "rm" and didn't take the media offline immediately after, then
no, not only not easy but probably impossible (depending on how active the
FS is)


> Sami
>
> --
> Sami Halabi
> Information Systems Engineer
> NMS Projects Expert, FreeBSD SysAdmin Expert
> Asterisk Expert
>


Re: recover deleted file

2022-04-16 Thread Sami Halabi
well.. thats the trivial answer.. the problem is backups is a day before...
if i can undelete it would save me loss of 1 day offset..

anyone?

On Sat, Apr 16, 2022 at 2:49 PM Matthias Apitz  wrote:

> El día sábado, abril 16, 2022 a las 02:23:25 +0300, Sami Halabi escribió:
>
> > Hi,
> > is there anyway easy to restore deleted file by accident in UFS
>
> Yes, restore it from a backup media.
>
> matthias
>
>
> --
> Matthias Apitz, ✉ g...@unixarea.de, http://www.unixarea.de/
> +49-176-38902045
> Public GnuPG key: http://www.unixarea.de/key.pub
>
> Peace instead of NATO!  Мир вместо НАТО!  Frieden statt NATO! ¡Paz en vez
> de OTAN!
>
>

-- 
Sami Halabi
Information Systems Engineer
NMS Projects Expert, FreeBSD SysAdmin Expert
Asterisk Expert


Re: recover deleted file

2022-04-16 Thread Matthias Apitz
El día sábado, abril 16, 2022 a las 02:23:25 +0300, Sami Halabi escribió:

> Hi,
> is there anyway easy to restore deleted file by accident in UFS

Yes, restore it from a backup media.

matthias


-- 
Matthias Apitz, ✉ g...@unixarea.de, http://www.unixarea.de/ +49-176-38902045
Public GnuPG key: http://www.unixarea.de/key.pub

Peace instead of NATO!  Мир вместо НАТО!  Frieden statt NATO! ¡Paz en vez de 
OTAN!



recover deleted file

2022-04-16 Thread Sami Halabi
Hi,
is there anyway easy to restore deleted file by accident in UFS

Sami

-- 
Sami Halabi
Information Systems Engineer
NMS Projects Expert, FreeBSD SysAdmin Expert
Asterisk Expert