473,411 Members | 2,210 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,411 software developers and data experts.

Restoring selected tables / table data

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. The SAS users
are laughing because they can (to a certain extend) easily go back to an
earlier SAS table by simply starting dsm. Of course, a flat file table is
different than a relational table; but still, the trouble related to
restoring DB2 data are resulting in massive table copying in the
databases.

I've read some of the DB2 recovery documentation by now. Am I right in
concluding that whenever I want to restore data (including dropped
tables) to a point in the past, it involves blocking the related
tablespace while restoring the data? - And that the only options to avoid
this are:

- restore the complete database to a specific point in time, using
a separate server (which entails setting up containers, etc, on
the separate server), or

- once in a while, dump all the tables to flat IXF files; but can
this be done in "uncommited read" mode, so that I minimize user
distubance (the users would then have to accept potentially
inconsistent data)

For cases where tablespace blocking is acceptable:
The tablespace typically contain many tables, and for most of them it
would be a disaster if I simply rolled the whole tablespace back to some
point in time. In other words: How do I restore a single table to a
specific point in time, without disturbing the rest of the tables in the
tablespace? Is the following possible:
1. roll the whole tablespace back to noon the day before
(entails a RESTORE)
2. export the relevant table to an ixf file
3. roll the whole tablespace further on to present time again
(entails another RESTORE, as far as I can see)
4. import the ixf file from step 2
If I have to go set up a dedicated db2 instance for restore operations:
Our production databases typically contain a large number of tablespaces,
potentially containing many containers. Is there a way to avoid having to
define all these structures in a restore-instance? - I.e.: Is there a way
to restore a complete database (to a point in time), telling DB2 to
ignore tablespace/container settings and just restore all schemas into
one single tablespace?

--
Regards,
Troels Arvin <tr****@arvin.dk>
http://troels.arvin.dk/
May 24 '07 #1
5 6531
Troels,

I think the "recover manager" can recover lost data from the logs.
It costs $$, but hey, there is an educational aspect to it :-)

Cheers
Serge

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
May 24 '07 #2
While stranded on information super highway Troels Arvin wrote:
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. The SAS users
are laughing because they can (to a certain extend) easily go back to an
earlier SAS table by simply starting dsm. Of course, a flat file table is
different than a relational table; but still, the trouble related to
restoring DB2 data are resulting in massive table copying in the
databases.

I've read some of the DB2 recovery documentation by now. Am I right in
concluding that whenever I want to restore data (including dropped
tables) to a point in the past, it involves blocking the related
tablespace while restoring the data? - And that the only options to avoid
this are:

- restore the complete database to a specific point in time, using
a separate server (which entails setting up containers, etc, on
the separate server), or

- once in a while, dump all the tables to flat IXF files; but can
this be done in "uncommited read" mode, so that I minimize user
distubance (the users would then have to accept potentially
inconsistent data)

For cases where tablespace blocking is acceptable:
The tablespace typically contain many tables, and for most of them it
would be a disaster if I simply rolled the whole tablespace back to some
point in time. In other words: How do I restore a single table to a
specific point in time, without disturbing the rest of the tables in the
tablespace? Is the following possible:
1. roll the whole tablespace back to noon the day before
(entails a RESTORE)
2. export the relevant table to an ixf file
3. roll the whole tablespace further on to present time again
(entails another RESTORE, as far as I can see)
4. import the ixf file from step 2
If I have to go set up a dedicated db2 instance for restore operations:
Our production databases typically contain a large number of tablespaces,
potentially containing many containers. Is there a way to avoid having to
define all these structures in a restore-instance? - I.e.: Is there a way
to restore a complete database (to a point in time), telling DB2 to
ignore tablespace/container settings and just restore all schemas into
one single tablespace?

--
Regards,
Troels Arvin <tr****@arvin.dk>
http://troels.arvin.dk/
How many tables do you have?
Maybe you can have one table per table space, that way you will not affect
other tables while restoring one table.
--
Hemant Shah /"\ ASCII ribbon campaign
E-mail: No************@xnet.com \ / ---------------------
X against HTML mail
TO REPLY, REMOVE NoJunkMail / \ and postings
FROM MY E-MAIL ADDRESS.
-----------------[DO NOT SEND UNSOLICITED BULK E-MAIL]------------------
I haven't lost my mind, Above opinions are mine only.
it's backed up on tape somewhere. Others can have their own.
May 24 '07 #3
On Thu, 24 May 2007 15:10:25 +0000, Hemant Shah wrote:
How many tables do you have?
"select count(*) from syscat.tables" yields 5276.
Maybe you can have one table per table space, that way you will not
affect other tables while restoring one table.
One table per tablespace is not realistic here. Of course, we can think
about table/tablespace refactorings, but most often, the mistakes happen
in tables/tablespaces with high activity.

--
Regards,
Troels Arvin <tr****@arvin.dk>
http://troels.arvin.dk/
May 25 '07 #4
aj
Hi Troels

Another approach is to just export the tables. I'm not sure about
the granularity you require, but 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. For
dropped tables, I would switch the Export to IXF format so you get
structure AND data. Run this as often as you need....

HTH

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,

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. The SAS users
are laughing because they can (to a certain extend) easily go back to an
earlier SAS table by simply starting dsm. Of course, a flat file table is
different than a relational table; but still, the trouble related to
restoring DB2 data are resulting in massive table copying in the
databases.

I've read some of the DB2 recovery documentation by now. Am I right in
concluding that whenever I want to restore data (including dropped
tables) to a point in the past, it involves blocking the related
tablespace while restoring the data? - And that the only options to avoid
this are:

- restore the complete database to a specific point in time, using
a separate server (which entails setting up containers, etc, on
the separate server), or

- once in a while, dump all the tables to flat IXF files; but can
this be done in "uncommited read" mode, so that I minimize user
distubance (the users would then have to accept potentially
inconsistent data)

For cases where tablespace blocking is acceptable:
The tablespace typically contain many tables, and for most of them it
would be a disaster if I simply rolled the whole tablespace back to some
point in time. In other words: How do I restore a single table to a
specific point in time, without disturbing the rest of the tables in the
tablespace? Is the following possible:
1. roll the whole tablespace back to noon the day before
(entails a RESTORE)
2. export the relevant table to an ixf file
3. roll the whole tablespace further on to present time again
(entails another RESTORE, as far as I can see)
4. import the ixf file from step 2
If I have to go set up a dedicated db2 instance for restore operations:
Our production databases typically contain a large number of tablespaces,
potentially containing many containers. Is there a way to avoid having to
define all these structures in a restore-instance? - I.e.: Is there a way
to restore a complete database (to a point in time), telling DB2 to
ignore tablespace/container settings and just restore all schemas into
one single tablespace?
May 25 '07 #5
On Fri, 25 May 2007 12:56:45 -0400, aj wrote:
Another approach is to just export the tables.
Yes, I thought about that. But I still need "true"==transactionally
consistent backupdata. So if I start dumping to flat files as well, my
storage consumption will rise rather dramatically -- and worse: as far as
I know, EXPORTing blocks the table being exported (right? - or can EXPORT
run in UR isolation mode?).
I'm not sure about the
granularity you require, but 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.
Thanks a lot for inspiration.

--
Regards,
Troels Arvin <tr****@arvin.dk>
http://troels.arvin.dk/
May 25 '07 #6

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? ...
0
by: Martin Hart | last post by:
Hi, postgresql 7.4beta4 on linux and postgresql 7.3.4 on linux We have a database that we routinely backup using "pg_dump -a" We have to do this (dump the data only) because of various...
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...
4
by: Troels Arvin | last post by:
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...
11
by: shriil | last post by:
Hi I have this database that calculates and stores the incentive amount earned by employees of a particular department. Each record is entered by entering the Date, Shift (morn, eve, or night)...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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.