Search

Join this Blog for direct reference of any post into your inbox. To join just click on "Join this Site" under "Follower" then Login with your Email.*** DECLARATION: I Maintain this Blog for Helping Myself While at Work and Welcome any body Needing Help!!!.*** CAUTION: Using any of the script from this Blog may contain at Own Risk. These scripts May or May not have been Tested.***

Wednesday, 23 May 2012

Script: How to Schedule Export Backup in Windows Env.

It is a simple script for exporting the entire database using “system” user today for Microsoft Windows based implementation. This batch file exports a .dmp file to a user specified directory.

FOR /F "tokens=2-4 delims=/ " %%a IN ('date/t') DO exp system/password@connectionstring full = y file=d:\backup\exp_%%b%%a%%c.dmp

Save this script inside a .bat or .cmd file (Eg: Exportbackup.bat or Exportbackup.cmd). Now schedule this batch file by using windows task schedular
HOW TO SCHEDULE TASK USING "SCHEDULED TASK"
Step1: Go to controlpanel click on "SCHEDULED TASK"
Click Next to Continue... then browse the file location and ADD it.

















Now right click go to properties of this (Export.bat) file and set the Start in: D:\Backup\Tested_Batch

then click on Apply and provide the OS password










Note: The username must have administrative privileges


Now set the Schedule Day, Time and click on OK

























There is no need to shutdown the database in order to facilitate the export. Once exported is completed it should look like as: exp_23052012.dmp
After estimating the completion time of job by runing this script 2 or 3 times. now you can schedule here a batch file to copy the backup from one server to another as an alternative backup to meet the situation of disaster. How to schdule the script to copy backup from live server to another server. check my older post for the same:

How to append date stamp on your Export dumps.
expdate='date '+%d%m%Y''
dat='date '+%m%d%y %H:%M:%S''
Now define in script:
On Unix:
./expdp system/system directory=export_dir dumpfile=exp_swx_$expdate.dmp logfile=exp_swx_$expdate.log schemas=swx
On Windows:
Date:  %date:~4,2%-%date:~7,2%-%date:~12,2%
Time:  %time:~0,2%-%time:~3,2%-%time:~6,2%
For Example:
copy C:\Trial.txt C:\Trail-%date:~4,2%-%date:~7,2%-%date:~12,2%.txt will output C:\Trial-mm-dd-yy.txt

exp edate/edate file=edate%date:~4,2%-%date:~7,2%-%date:~12,2%.dmp log=edate%date:~4,2%-%date:~7,2%-%date:~12,2%.txt owner=edate statistics=none

http://shahiddba.blogspot.com/2012/03/script-to-copy-or-move-backup-from-one.html

2 comments:

  1. Date: %date:~4,2%-%date:~7,2%-%date:~12,2%
    Time: %time:~0,2%-%time:~3,2%-%time:~6,2%
    For Example:
    copy C:\Trial.txt C:\Trail-%date:~4,2%-%date:~7,2%-%date:~12,2%.txt will output C:\Trial-mm-dd-yy.txt

    exp edate/edate file=edate%date:~4,2%-%date:~7,2%-%date:~12,2%.dmp log=edate%date:~4,2%-%date:~7,2%-%date:~12,2%.txt owner=edate statistics=none

    after running this script then cmd prompt ask to enter a new date. its cant get automatic date and time how can i resolve it. when script is run then cmd promt msg showing the systemm cannot accept the date entered.
    Enter the new date

    ReplyDelete