If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > copy logs for backup

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-30-03, 18:36
preetim preetim is offline
Registered User
 
Join Date: Jun 2003
Posts: 77
Post copy logs for backup

Hi All,

We are implementing a backup and restore policy for DB2v7.2 on windows 2000/NT server, using online backup and user exit to archive logs.

First we want to copy the archived logs to tape, then do a db2backup and then copy the backup to tape (so that we'll keep the logs created during the backup on disk).

I've two questions-

1. I want to make one .bat / .cmd file to do the file copy and start db2 backup. My problem is, when I give db2cmd db2 backup db ...., the next command starts without waiting for the backup to complete. How can I combine the above 3 jobs to run from one script such that one process starts only when the other finishes?

2. What should be done for the logs which can be generated between the time of copying the archived logs to tape and taking the backup. This is a small window of time but still there is a probability of such a situation to occur.
Is there a way to suspend and resume archiving of logs ?

Yor responses would be a great help. Thanks in advance.
-Preeti
Reply With Quote
  #2 (permalink)  
Old 12-30-03, 18:46
preetim preetim is offline
Registered User
 
Join Date: Jun 2003
Posts: 77
Hi ,
I got the solution of my first problem.

I'm using db2cmd -w option. It works. Still, let me know if someone know any better option.

Thanks
Reply With Quote
  #3 (permalink)  
Old 12-31-03, 09:02
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
For 1, yes, this is the best option afaik

For 2,
I'm not sure why you wish to suspend archiving during the period of the backup ... If you wish to use the backup you will need the logs genrated when the backup is happening for performing a successful rollforward ...

Please let me know if I am not clear or post more details on why you wish to do this ..

Cheers
Sathyaram
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #4 (permalink)  
Old 12-31-03, 10:41
cchattoraj cchattoraj is offline
Registered User
 
Join Date: Mar 2003
Posts: 343
To recover from an online backup, you will need all archived logs right upto right after the backup(minimum point in time) to recover from it. Maybe if you do the archive log disk copy after the backup and set the registry variable DB2_DISABLE_FLUSH_LOG to NO(DEFAULT) then it should be OK.

Archiving can be suspended by using set write suspend - however, it is not recommended for backups - only for flashcopy. This leaves any application which tries to connect and does something which requires logging to be in a wait state.

Hope this helps
Reply With Quote
  #5 (permalink)  
Old 01-02-04, 12:11
preetim preetim is offline
Registered User
 
Join Date: Jun 2003
Posts: 77
Thanks for your replies and wish you a very happy New Year.
This forum has been a great help to me.

What I'm doing for a backup is -

1. copy the archived logs from disk to Tape.
2. delete the archived logs on disk.
3. do the db2 backup on disk.
4. copy the backup from disk to Tape.

My concern is- what if some log gets written to the archived logs folder on disk between copy command and delete command(and gets deleted without being copied).
We are giving copy and delete command serially from a batch script.
I dont know if this is a possibility or not.
Please let me know if its okay to overlook such chances.

After reading both responses to my posting, I think " log suspend " is not suitable for anything like this. That was my mistake.

Also, I would like to know what is an appropriate way to script this process(copy logs, copy backup etc ) so that error handling could be done (since we've to hand over an automated backup process to customers). Do people use Python/C/C++ for this?
Reply With Quote
  #6 (permalink)  
Old 01-02-04, 13:47
cchattoraj cchattoraj is offline
Registered User
 
Join Date: Mar 2003
Posts: 343
I do not think it is a good idea to delete anything directly from the archive log directory, the reason being that db2 reuses logs, holds on to logs while a transaction is active, changes log sequence under certain circumstances and there are certain configuration parms which affect what db2 expects to find in the directory at certain times. Therefore it is difficult to determine which logs are active at a point in time. And as DBAs, I'm sure we all struggle to determine what to do. I would think that you could modify the userexit program under $insthome/sqllib/samples/c and make db2 archive logs to (other) disk. Then it should be safer to copy these logs from other disk, because now you are aware that they are truly archived and not active. About deleting, I'm sure that there is manner in which you can delete only those files which are copied - maybe generate a lock file with a list of files which will be copied and delete those files only. This will prevent loss of archive logs. Archive logs are very important where online backups are concerned. It is actually a good idea to be extremely cautious about deleting archive logs.

As far as handling this we use shell scripts, however, I am sure you could code this into any language using Administrative API calls. Look up the Administrative API reference.

Hope this helps.
Reply With Quote
  #7 (permalink)  
Old 01-02-04, 14:38
preetim preetim is offline
Registered User
 
Join Date: Jun 2003
Posts: 77
Thanks for your response, its certailnly very helpful.

When I mentioned that we are deleting the contents of archived logs directory after copying the logs to tape, I meant the directory where the logs are directed to as a result of user exit program that we are already using. We are not deleting anything from the active logs directory.
I should have made it more clear. Sorry about that.

Please let me know if you know of any harmful impacts of deleting even these logs (sent to the mylogs folder by user exit program).

Thanks for your idea of generating a list of files copied and deleting only those. I'll look more into it and hopefully I'll find something in the Administrative API of C.





Quote:
Originally posted by cchattoraj
I do not think it is a good idea to delete anything directly from the archive log directory, the reason being that db2 reuses logs, holds on to logs while a transaction is active, changes log sequence under certain circumstances and there are certain configuration parms which affect what db2 expects to find in the directory at certain times. Therefore it is difficult to determine which logs are active at a point in time. And as DBAs, I'm sure we all struggle to determine what to do. I would think that you could modify the userexit program under $insthome/sqllib/samples/c and make db2 archive logs to (other) disk. Then it should be safer to copy these logs from other disk, because now you are aware that they are truly archived and not active. About deleting, I'm sure that there is manner in which you can delete only those files which are copied - maybe generate a lock file with a list of files which will be copied and delete those files only. This will prevent loss of archive logs. Archive logs are very important where online backups are concerned. It is actually a good idea to be extremely cautious about deleting archive logs.

As far as handling this we use shell scripts, however, I am sure you could code this into any language using Administrative API calls. Look up the Administrative API reference.

Hope this helps.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On