Regarding: Script For Backup And As Well As Copy From Local Machine To Snap Drive In Windows.

12 views
Skip to first unread message

venkata ganesh kumar yerra

unread,
Oct 25, 2007, 2:02:59 PM10/25/07
to mirac...@googlegroups.com
Hi All,
 
This is the windows script for taking database backup and immediately copy those backup files from local drive to SNAP Drive.(Storage device).
 
Here Script1: CADEV_Backup.bat.
 
In that CADEV_Backup.bat script we are having OFFLINE Backup process.(see the below code)
 
db2 CONNECT TO CADEV
db2 QUIESCE DATABASE IMMEDIATE FORCE CONNECTIONS
db2 CONNECT RESET
db2 BACKUP DATABASE CADEV TO D:\DB2BK,E:\DB2BK COMPRESS
db2 CONNECT TO CADEV
db2 UNQUIESCE DATABASE
db2 CONNECT RESET
 
Script2: CADEV_BackupCopy.bat
 
In this script you can give the backup script path (D:\WorkArea\Manual_Backup\CADEV_Backup.bat) see the below script. Just run the script2 when you want to take the offline backup and also copy the images from local machine to SNAP Drive(SNAP Drive = Where you want to store the backup files).
 
In the backup script i splited the database backup into two diffrent drives.(For the Reason of space issue)
 
rem *************** DB2 ****************
time /t
echo CADEV Backup Started

set PATH=%PATH%;C:\IBM\SQLLIB\BIN
db2cmd -c -w -i "D:\WorkArea\Manual_Backup\CADEV_Backup.bat"

echo CADEV Database Backup Finished
time /t
rem *************** DB2 ****************

rem *************** DB Backup copy to SNAP drive 8.51
echo Backup copying Started
rem ****Map network drive
net use x:
\\<IP Address of the snap drive>\ <Password For Snap drive> /user:<Username For Snap drive>


echo CADEV Backup copying Started
md X:\%computername%\CADEV_Backup
copy D:\DB2BK\*.* X:\CADEV_Backup
copy E:\DB2BK\*.* X:\CADEV_Backup
echo DB2 CADEV database backup copying complete

rem *************** DB2 ****************

Thanking You.
 
Please let me know if any issues.

--
Thanks & Regards,
Venkata.Ganesh kumar.Yerra,
Symphony Services (India) Pvt Ltd,
Direct Line : 080-3027-2893
Mobile : 09740221212

malla kishore

unread,
Oct 26, 2007, 1:45:01 AM10/26/07
to mirac...@googlegroups.com
Hi Ganesh,

Thanks for the information sharing ..Please can you let us know how to check the backup ising db2ckbkp for the partitioned backup..

Thanks in advance
kishore
--
కిశోర్ మల్ల

Satish Mullapudi

unread,
Oct 26, 2007, 4:27:36 AM10/26/07
to mirac...@googlegroups.com
Hi All,
 
The main reason to go for partitioned backup images (database image will be taken in parts, ie, the same image is broken down, it NOT for partitioned dbs) is to accomodate the backup image in the filesystem space available.
 
Lets take a scenario:
C:\ 100MB Available free space
D:\ 100MB Available free space
E:\ 100MB Available free space
But here the size of our database (SAMPLE) is aprox. 250MB. Now how can we take the backup image, because neither of the drive can accomodate the complete backup image of 250MB due to lack of free space.
For this reason, there is a remedy for this. Instead of going for a single drive, we take the backup into all the 3 drives as given below:
 
db2 BACKUP DATABASE Sample TO c:\backups,d:\backups,e:\backups WITH 2 BUFFERS BUFFER 1024 WITHOUT PROMPTING
 
This cmd, partitions the database image into parts. All the 3 images in the 3 drives are created at once & each image is written in a round robin fashion to ensure that data is distibuted equally among all the images. 
Now, the images will have the names as :
C:\backups\SAMPLE.0\DB2\NODE0000\CATN0000\20071026\123632.001
D:\backups\SAMPLE.0\DB2\NODE0000\CATN0000\20071026\123632.002
E:\backups\SAMPLE.0\DB2\NODE0000\CATN0000\20071026\123632.003
 
Now, to check the integrity of these backup images using db2ckbkp:
 
db2ckbkp <path of 1st bkp image> <path of 2nd bkp image> ......
(each fully qualified image name seperated by SPACES)
 
Ex: db2ckbkp C:\backups\SAMPLE.0\DB2\NODE0000\CATN0000\20071026\123632.001 D:\backups\SAMPLE.0\DB2\NODE0000\CATN0000\20071026\123632.002  E:\backups\SAMPLE.0\DB2\NODE0000\CATN0000\20071026\123632.003
 
[1] Buffers processed:  ##################################
[2] Buffers processed:  ##################################
[3] Buffers processed:  #############################

Image Verification Complete - successful.

Now, if u want to restore from the partitioned backup images:
 
db2 RESTORE DB Sample FROM c:\backups,d:\backups,e:\backups  TAKEN AT 20071026123632 REPLACE HISTORY FILE WITHOUT PROMPTING
 
Now, the Restore operation fetches the data from all the images mentioned above round-robin
fashion and restores the database.
 
I guess this info. answers the question asked.
 
If you have any questions reg. this concept feel free to put them up.


Miracle Software Systems Inc.
email: smull...@miraclesoft.com
Mobile: +919923020321
Reply all
Reply to author
Forward
0 new messages