1

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).

4
  • 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. Aug 8, 2012 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, 2012 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? Aug 9, 2012 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, 2012 at 13:12

4 Answers 4

1

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.

4
  • 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, 2012 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. Aug 9, 2012 at 13:26
  • Something else like Perl? ;-)
    – WarrenT
    Aug 10, 2012 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. Aug 10, 2012 at 12:47
1

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'

1

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.

1
  • you should try db2move - that brings the DDL (minus tablespaces and bufferpools) + the data. Run a db2move <database-name> export. Aug 14, 2012 at 19:00
1

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 ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.