Unix Technical Forum

Recovering deleted data

This is a discussion on Recovering deleted data within the Informix forums, part of the Database Server Software category; --> Writing from another box now, so I can't 'reply'. 1 - Best option is always a restore. 2 - ...


Go Back   Unix Technical Forum > Database Server Software > Informix

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-19-2008, 09:26 PM
Jack Parker
 
Posts: n/a
Default Recovering deleted data



Writing from another box now, so I can't 'reply'.

1 - Best option is always a restore.

2 - (onlog) I suspect that onlog will only report that a row was deleted,
not show the data that was deleted. I was thinking of a logged update when
I replied earlier. Hmmm, when I try it out I can actually see the data from
the row which was deleted (HDELETE)

3 - (raw data)
a) Figure out what the pages are that your table is stored on:
oncheck -pt database:table
look at the Extents listing - this is where your table is (physical),
the first number is the chunk (compare that onstat -d)
second number is the offset.

b) Dump those pages:
dd if=device bs=pagesize skip=offset+1 count=npages
(rinse and repeat for every set of extents)

device is what you found on onstat -d
offset is what oncheck -pt reported. Mind you the first page is the table
header, the second page is a bitmap, but then the counting starts at 0, not
1, so just add 1 - this time.
npages is how many pages there are in this extent (min that in the first
extent, you lost two pages to header and bitmap, you will also have a bitmap
page every <pagesize> pages.
So if your first extent is 8 pages, then add one to offset, for the second
extent, SUBTRACT 1 from the offset as there is no longer a table header nor
a bitmap. Follow?

You could also use oncheck -pP chunk offset which will yield you cleaner
output, if it can be interpreted. Except that this will not display deleted
data.

Depending on your engine the first 24 bytes is page header. You will also
have to understand the slot table at the end of each page - which points to
the data in question (or rather doesn't if the row has been deleted). This
works backwards from the end of the page. The 'last' (first if you are
reading properly from right to left) 4 bytes are a time stamp. Each
additional 4 bytes is a pointer to the offset into the table for the row and
the row length. If the offset is 0, the row has been deleted.

I don't know (not sure I ever did) if it's possible for a slot entry to be
re-used and directed somewhere else, but if you eliminate all of the slot
table offsets that point to real data, everything else is your deleted data.

c) ... through a parser which you will probably have to come up with on your
own.

Character data is easily recognizable, numeric data is fairly
straightforward as well. It's the sort of thing you'd do with one hand on
the SQL Reference manual chapter 2.

Of course this all assumes that nobody did an update which required a
re-write or an insert since the deletion occurred, and that no compresses
have occurred on the cleaned pages. Whatever the case, this is by no means
a guaranteed retrieval of lost data, some of it will indeed be gone - hence
the reluctance of anybody official saying that they could do something -
your database integrity is basically shot.


Ah well. Have I scared you off yet? As I said, the best option is a decent
backup.

cheers
j.


sending to informix-list
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 11:21 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com