Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Db2 v10.5 database backup automate using bat file

482 views
Skip to first unread message

randi....@illinois.gov

unread,
Jul 19, 2016, 3:39:37 PM7/19/16
to
OS is Windows Server 2012 R2 Standard
DB2 is luw v10.5.700.375

Created a batch file that will backup several databases over night. I start at the DOS Command prompt on the server and call DB2cmd as a line command. The problem is I cannot seem to get the CLP and Command prompt windows to close when the backups have concluded. I have tried adding the following commands "quit", "terminate", and "exit". Please provide solutions or suggestions. Thank you for any help!!

TheBoss

unread,
Jul 19, 2016, 4:13:16 PM7/19/16
to
randi....@illinois.gov wrote in
news:64eceeab-d1d7-4f67...@googlegroups.com:
Hi Randi,

first a disclaimer: I've never worked with DB2 on a Windows platform, so I
have no real life experience with what you are trying to do.
That being said, I think you might take advantage of the following article
on IBM's developerWorks site:
http://www.ibm.com/developerworks/data/library/techarticle/0307fierros/0307
fierros.html

If my interpretation is correct, you specifically could have a look at:

- Table 2, showing the options for the DB2 command window.
- Listing 3, an example backup script invoked from a Windows shell.

My guess is that you will need the '-c' switch.


HTH.

--
Jeroen

bwmil...@gmail.com

unread,
Aug 1, 2016, 11:34:26 AM8/1/16
to
Here is how you do it:

In your windows script:

db2cmd -c call db2_backup_daily.cmd


then in another script called db2_backup_daily.cmd

db2 backup database <DB> user <USER> using <PASSWORD> online to C:\PATH compress include logs without prompting

Jeremy Rickard

unread,
Aug 16, 2016, 9:24:46 PM8/16/16
to
Since scripting on Windows isn't so nice, you might also consider other options, e.g.:

* Use DB2 automated backups with a suitable window defined. This may not offer enough control for you.

* Use an SQL approach (BACKUP through ADMIN_CMD routine); you can then make those calls via ODBC or JDBC rather than relying on a perhaps flaky interaction between DOS and db2cmd.
0 new messages