473,399 Members | 3,106 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Restoring selected tables

Hello,

I've run into situations where a table was accidentally dropped. The
related database contained lots of other tables in lots of other schemas
used by many different users. So I couldn't simply recover to a previous
point in time (the other users' changes would be lost and/or there would
be periods of no database availability).

It seems that my only option was a complete, redirected restore. (Compete,
because redirected restore operations can't operate on selected
tablespaces). As some of our databases are very large, a complete,
redirected restore takes a lot of time.

This turns out being a problem.

What are my options? I'm considering supplementing our regular (TSM)
online backup scheme with daily dumps to raw files, based on EXPORT and
db2look. With a little text massage of the dumps, I would be able to
restore selected tables without going through RESTORE. - And in some cases
this would be fine because the dropped table(s) might not have been
updated recently. Is my thinking (in)sane?

--
Regards,
Troels Arvin <tr****@arvin.dk>
http://troels.arvin.dk/
Jan 31 '07 #1
4 2362
I presume you are running DB2 V8 on LUW.
At that level, every tablespace is automatically created with a parm the
enables DROPPED TABLE RECOVERY.
When the table is dropped, DB2 writes in the log file a unique transaction
id with the drop command.
The same info is also wrtitten in the DB2DIAG.LOG file with the DDL of the
table.
Do: db2 list history DROPPED all to see the messages.

To recover:
Restore the tablespace of the table and roll it forward to end of logs.
The ROLLFORWARD command wil HAVE TO specify [RECOVER DROPPED TABLE
dropped-table-id TO export-directory]
The id you get from the db2diag.log and you specify the directory. The file
is DEL format.
After successful roll forward, you can use the DDL to create the table **
and the data will be in the export directory.

If you are at V7, then the tblspaces had to have been created or ALTERed
with DROPPED TABLE RECOVERY ON. If not, you are back to where you were in
your note.

Hope this helps, Pierre.
PS: If you know (guess) what tables are candidates for drop, runninf db2look
to extract the DDL before hand will save you time as you can keep that in a
file and use it where I typed **

--
Pierre Saint-Jacques
SES Consultants Inc.
514-737-4515
"Troels Arvin" <tr****@arvin.dka écrit dans le message de news:
ep**********@news.net.uni-c.dk...
Hello,

I've run into situations where a table was accidentally dropped. The
related database contained lots of other tables in lots of other schemas
used by many different users. So I couldn't simply recover to a previous
point in time (the other users' changes would be lost and/or there would
be periods of no database availability).

It seems that my only option was a complete, redirected restore. (Compete,
because redirected restore operations can't operate on selected
tablespaces). As some of our databases are very large, a complete,
redirected restore takes a lot of time.

This turns out being a problem.

What are my options? I'm considering supplementing our regular (TSM)
online backup scheme with daily dumps to raw files, based on EXPORT and
db2look. With a little text massage of the dumps, I would be able to
restore selected tables without going through RESTORE. - And in some cases
this would be fine because the dropped table(s) might not have been
updated recently. Is my thinking (in)sane?

--
Regards,
Troels Arvin <tr****@arvin.dk>
http://troels.arvin.dk/
Jan 31 '07 #2
aj
No, I don't think your thinking is insane. In fact, here's a shell
script that dumps pipe delimited ascii backups of specified files,
keeping 5 versions worth and compressing them to keep disk space down.
Assuming daily runs, as long as you realize within 5 days, you can
get table data back. For dropped tables, I would switch the Export
to IXF format so you get structure AND data..

You know this, but remember this is not Point In Time (PIT) Recovery!!
Its only as good as the last run. This, combined w/ some audit trail
stuff of mine, has gotten me out of trouble a few times..

Don't know what OS you have. Mine is Linux.

cheers

aj

################################################## ##############
# This script backs up database tables in ascii format

cd /db2/backups/ascii

echo "connect to <MYDB;" /db2/backups/ascii/backup.sql
echo "set schema <MYSCHEMA;" >/db2/backups/ascii/backup.sql

# ************************************************** ***************
for table in <LIST TABLES, SPACE DELIMITED, YOU WANT TO BACK UP>
do
if [ -s $table.5.gz ]
then
rm $table.5.gz
fi

if [ -s $table.4.gz ]
then
mv $table.4.gz $table.5.gz
fi

if [ -s $table.3.gz ]
then
mv $table.3.gz $table.4.gz
fi

if [ -s $table.2.gz ]
then
mv $table.2.gz $table.3.gz
fi

if [ -s $table.1.gz ]
then
mv $table.1.gz $table.2.gz
fi

if [ -s $table.txt.gz ]
then
mv $table.txt.gz $table.1.gz
fi

echo $table
done | /usr/bin/awk '
NF == 1 {
printf("EXPORT TO %s.txt OF DEL MODIFIED BY coldel| chardel\"\"
decpt. decplusblank datesiso MESSAGES %s.msg SELECT * FROM %s
;\n",$1,$1,$1) ;
}' >/db2/backups/ascii/backup.sql

echo "connect reset ;" >/db2/backups/ascii/backup.sql
db2 -tvf /db2/backups/ascii/backup.sql
################################################## ##############
Troels Arvin wrote:
Hello,

I've run into situations where a table was accidentally dropped. The
related database contained lots of other tables in lots of other schemas
used by many different users. So I couldn't simply recover to a previous
point in time (the other users' changes would be lost and/or there would
be periods of no database availability).

It seems that my only option was a complete, redirected restore. (Compete,
because redirected restore operations can't operate on selected
tablespaces). As some of our databases are very large, a complete,
redirected restore takes a lot of time.

This turns out being a problem.

What are my options? I'm considering supplementing our regular (TSM)
online backup scheme with daily dumps to raw files, based on EXPORT and
db2look. With a little text massage of the dumps, I would be able to
restore selected tables without going through RESTORE. - And in some cases
this would be fine because the dropped table(s) might not have been
updated recently. Is my thinking (in)sane?
Jan 31 '07 #3
On Wed, 31 Jan 2007 16:58:59 -0500, Pierre Saint-Jacques wrote:
I presume you are running DB2 V8 on LUW.
At that level, every tablespace is automatically created with a parm the
enables DROPPED TABLE RECOVERY.
The version is 8.1.1.96 (from db2level), but I believe that the particular
database was created some versions before the current DB2 generation.

When I check the tablespaces, almost all of them have DROP_TABLE=N. I
suspect that the particular database defaults to DROP_TABLE=N for new
tablespaces. Is there a way to specify that the default DROP_TABLE state
should be Y for future tablespaces?

Thanks for your detailed description, by the way.

--
Regards,
Troels Arvin <tr****@arvin.dk>
http://troels.arvin.dk/
Feb 1 '07 #4
If your V8 tblspces show DROP_TABLE=N, it is because they were migrated from
versions lower than V8 .
For each of the pre-V8 tablespaces, you will need to use:
ALTER TABLESPACE tbspacename...DROPPED TABLE RECOVERY ON
Every tablespace you create post V* install will automatically have the DROP
ON. It is the default for all new cpaces as of V8.1.1
Regards, Pierre.

--
Pierre Saint-Jacques
SES Consultants Inc.
514-737-4515
"Troels Arvin" <tr****@arvin.dka écrit dans le message de news:
ep**********@news.net.uni-c.dk...
On Wed, 31 Jan 2007 16:58:59 -0500, Pierre Saint-Jacques wrote:
>I presume you are running DB2 V8 on LUW.
At that level, every tablespace is automatically created with a parm the
enables DROPPED TABLE RECOVERY.

The version is 8.1.1.96 (from db2level), but I believe that the particular
database was created some versions before the current DB2 generation.

When I check the tablespaces, almost all of them have DROP_TABLE=N. I
suspect that the particular database defaults to DROP_TABLE=N for new
tablespaces. Is there a way to specify that the default DROP_TABLE state
should be Y for future tablespaces?

Thanks for your detailed description, by the way.

--
Regards,
Troels Arvin <tr****@arvin.dk>
http://troels.arvin.dk/
Feb 2 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Terry | last post by:
I am trying to move a datbase from one machine to another. I have tried two different methods and neither are working. First I tried using : >> mysqldump dbName > backup_file.sql >> mysql...
2
by: Yair Sageev | last post by:
Greetings. I was running PHP Nuke on a Win2k box using Apache2Triad. Fortunately I backed up the drive using windows backup prior to the hard drive failure. Now I have installed Apache2Triad...
2
by: Raffi | last post by:
I use the --all-databases switch to backup my entire database. Sometimes there's a need to restore individual databases or tables form the backup file. What command should I use for this? ...
5
by: wanchan | last post by:
Dear all, Is it possible to restore some (not all) tablespaces to a new database? We have a full offline backup, and as the manual says, we can restore the whole set of tablespaces to a new...
5
by: Mike Nolan | last post by:
I have a 600K row table on my production system (running 7.3.3) that I dump and load on my development system (7.4.1) every night using cron jobs. I would like to be able to restore the table...
3
by: rdemyan via AccessMonster.com | last post by:
I'm thinking about providing a relatively easy method for users to restore the front end from a backup. The purpose is to allow for restoring if the front end becomes corrupt. Here are some...
2
by: chenert | last post by:
Hi all, im beginner to restoring dump files and postgresql as well so hope u could bear with me.! :D i have these dump files and i've been working on restoring everything in it. i've tried...
5
by: Troels Arvin | last post by:
Hello, Every so often, I'm asked to help people recover data from tables that were either dropped or where to much data was DELETEed. The complications related to restoring data are a problem....
3
by: andersond | last post by:
I have a webpage that uses visible and hidden tables to create the effect of going from screen to screen. Because a user might want to go back and change previous selections I have a "previous page"...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.