Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What could be the best approach ?

Till now could figure out the following (Oracle)

  1. Calling exp.exe and imp.exe utilities in Oracle client using Java and inturn call it from Perl.
  2. Calling exp.exe and imp.exe utilities in Oracle client directly from Perl.
  3. Explore more of DBI, DBD modules.
  4. Search for some commands and execute them by connecting to respective databases

New to Perl and database(DB2, SQL Server).

share|improve this question

migrated from Aug 9 '12 at 12:33

This question came from our site for professional and enthusiast programmers.

What is the business problem you are trying to solve? Normally, when people talk about backing up an Oracle database, they are trying to generate a physical backup. Not a logical backup using the Oracle export utility. – Justin Cave Aug 8 '12 at 15:02
The requirement is basically meant to backup the data and at a later point could import the data back. I guess for oracle using the exp and imp command would be fine. Need to figure out something for DB2, SQL Server. – user762421 Aug 9 '12 at 7:03
OK, so there is no need to be able to apply any of the committed transactions that were made after you captured your copy of the data? You just want to be able to restore the point-in-time data that was present in the database when you generated the logical backup? – Justin Cave Aug 9 '12 at 13:02
You didn't even mention what operating system this is for. I guess we can assume some version of Windows because you mentioned SQL Server. But DB2, Oracle, and Perl can run in many other environments. – WarrenT Aug 9 '12 at 13:12

Backing up in DB2 is pretty simple. You use the DB2 Backup Database command (command line). You can invoke this via scripting language if you wish (I highly recommend it). We run AIX at our shop, so we use ksh scripts that are called by cron jobs to make sure we run backups of the database.

Restores we do "manually". We still have them scripted, but we invoke them only when needed.

share|improve this answer
Perl is an even nicer scripting language. Does SQL Server somehow run on AIX, now? This seems to be a Windows question. – WarrenT Aug 9 '12 at 13:23
Not sure about SQLServer on AIX. As for DB2 on Windows, the commands still hold true, you just have to switch to Windows Batch script or PowerShell or something else. – Chris Aldrich Aug 9 '12 at 13:26
Something else like Perl? ;-) – WarrenT Aug 10 '12 at 4:48
@WarrenT - ok you got me. :) I just am not familiar with Perl. So I can't speak to it. My experience has been mostly shell scripts. – Chris Aldrich Aug 10 '12 at 12:47

Backing up SQL Server is very easy. Simply log into the database engine and run the BACKUP DATABASE statement. Give it a file to backup to and let it run. You'll need permissions to backup the database of course.

BACKUP DATABASE MyDatabase TO DISK='C:\SomePath\SomeFile.bak'

share|improve this answer

Able to call 'exp' in case of oracle from Perl script. Seems to solve the purpose. One thing that i faced is the incompatibility of the oracle client version and the server version. The client cannot be newer than the server.

In case of DB2 also explored 'db2look' system command but it only extracts the DDL. 'Export' command requires the user to provide a select query the result of whose will be exported. So Calling 'backup' command from Perl script. One interesting thing is that the console from which the backup command is to be called needs to be invoked from db2cmd. So the Perl script variable may look like : $cmd = "db2cmd -c db2 backup database $database to $backupDir"; db2cmd needs to be initialized first.

share|improve this answer
you should try db2move - that brings the DDL (minus tablespaces and bufferpools) + the data. Run a db2move <database-name> export. – Chris Aldrich Aug 14 '12 at 19:00

For performing backup and restore remotely on client machines, 1. SQL Server : I guess have to take backup on server machine itself and then copy it to local client machine. 2. DB2 : Exploring the clients. Does commands like backup, db2move can be used directly from the client like Oracle's exp and imp ?

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.