a Backup Headscratcher.....

Author
Discussion

GregE240

Original Poster:

10,857 posts

272 months

Thursday 29th April 2004
quotequote all
DB2 backup.

Now, before you all run away, I only want to delete the file once its been backed up!

Heres the situation:

I have 4 DB2 databases on a Wintel server that need backing up. I don't have a DB2 plugin for BackupExec so I'm doing it via the following method:
1) Stop the database
2) Use a DB2 backup command to snapshot the database into a folder (D:/DB2BACKUP)
3) Start the database
4) Run the backup job

Now, this would all be fine, but DB2 places it into the following folder structure under D:/DB2BACKUP:

DB2/NODE0000/CATN0000/20040429

What I want to do once the backup has finished is delete the 20040429 folder and the DB2 file within it. Herein lies the problem. The folder is basically todays date, so I need a way of capturing what that folder is called. Initially I thought I could simply use the DOS RD command but that relies on you knowing what the folder is called. If I ran it one level up (i.e. at CATN0000) it would also delete other files that may legitimately be there, so I can't do that.

Any ideas? Its got me a bit

>>> Edited by GregE240 on Thursday 29th April 15:11

Plotloss

67,280 posts

275 months

Thursday 29th April 2004
quotequote all
Are Node0000 and Cat0000 statics?

If so build the string and then pass using todays date (I may be able to sort you out a Date7 conversion program tommorow (not at work)) today as an argument to a batch file and do the delete from there?

Alternatively swerve the backup process and use DTS to fill a file on SQL Server.

Any good?

GregE240

Original Poster:

10,857 posts

272 months

Thursday 29th April 2004
quotequote all
Plotloss said:
Are Node0000 and Cat0000 statics?


You're right Matt, they are. For example, you might have sub folders like:

/20040429
/20040331

And so forth. DB2 creates the folder based on the date, as you say.
Plotloss said:

If so build the string and then pass using todays date (I may be able to sort you out a Date7 conversion program tommorow (not at work)) today as an argument to a batch file and do the delete from there?

I think that will do it. As I said, RD removes the folder you run it from too, so no good running at the CAT0000 level as you may remove a load of other databases!
Plotloss said:

Alternatively swerve the backup process and use DTS to fill a file on SQL Server.
Any good?

DTS probably isn't an option, but I like your first idea Matt - thanks mate.

size13

2,032 posts

262 months

Thursday 29th April 2004
quotequote all
if you want to delete all the folders under CATN0000, can't you just do rd /q /s . it throws up an error, but it still deletes all the sub directories

Make sure you're in DB2/NODE0000/CATN0000 when you do it

>> Edited by size13 on Thursday 29th April 15:53