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

Tuesday, 24 April 2012

Script to Copy backup from one server to another server

Tested on Windows XP, Windows 2003
The key to automated backup is the use of a batch file. In Windows, you can create one using Notepad by putting the extension .BAT. The thing to remember is that it must be a pure ASCII text file.

After the weekly and daily backup you can also schedule one of suitable below batch file to copy or move your backup from one server to another. Before going to use check your date format:
Check date format: Echo %date% or echo |date/T
Check Time firmat: Echo %time% or echo |time/T
Switches with the delete command:
/P Prompts for confirmation before deleting each file.
/F Force deleting of read-only files.
/S Delete specified files from all subdirectories.
/Q Quiet mode, do not ask if ok to delete on global wildcard
/A Selects files to delete based on attributes
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
@This script is able to copy all files of entered date by the  user from source to destination.

@echo off
set /p copyDate=Please input the date as MM/DD/YYYY.
echo You enter %copyDate%
xcopy \\192.166.24.02 \d$\BACKUP_RMAN_DB\Hotbackup \\192.166.21.01\h\Rman_DBbackup /D:%copyDate%

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
@This scheduled script will copy all file from source to destination. There is no need to enter the date it will pick the sysdate.

set path=c:\WINDOWS\system32;
@echo off
for /F "tokens=2-4* delims=/ " %%A in ('DATE/T') do set MMDDYY=%%B-%%A-%%C

echo Copying started at %date% %time%>>Copy_date_.txt
xcopy \\192.168.14.32\d$\BACKUP_RMAN_DB\Hotbackup \\192.166.21.01 \h\Rman_DBbackup /D:%MMDDYY%

echo Copying finished at %date% %time%>>Copy_date_.txt
echo Completed Successfully at %date% %time%>>Copy_date_.txt
echo --------------------------------------------------------------------------- >>Copy_date_.txt
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
@The script will delete first destination folder file then copy all the files from source to destination. It will also write starting and ending of copy time in the test file.

set path=c:\WINDOWS\system32;
@echo off
cd \\192.166.21.01 \h\Rman_DBbackup
del \\192.166.21.01 \h\Rman_DBbackup\*.* /q
cd D:\BACKUP_RMAN_DB\Logs

echo Copying started at %date% %time%>>Copy_date_.txt
xcopy \\192.166.24.02 \d$\BACKUP_RMAN_DB\Hotbackup \\192.166.21.01 \h\Rman_DBbackup /Y /a /d

echo Copying finished at %date% %time%>>Copy_date_.txt
echo Completed Successfully at %date% %time%>>Copy_date_.txt
echo --------------------------------------------------------------------------- >>Copy_date_.txt

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
The script will copy all the file including hidden and subdirectories if the file already existed on destination folder it will ignore that file by minimizing the copy time.

@echo off
xcopy \\ittest\d$\BACKUP\RMAN\Test \\192.166.24.02\i$\oraback\Check /D /S /E /H

echo Copying finished at %date% %time%>>_date_.txt
echo Completed Successfully at %date% %time%>>_date_.txt
echo --------------------------------------------------------------------------- >>_date_.txt

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
@The scheduled script will generate fix date file from source to destination. you have to change
date manually each and every week after the full backup.

@echo off
set path=c:\WINDOWS\system32;

xcopy \\ittest\d$\BACKUP\RMAN\Test \\192.166.24.02 \i$\oraback\Check /Y /D:04/23/2012
echo Copying finished at %date% %time%>>_date_.txt
echo Completed Successfully at %date% %time%>>_date_.txt
echo --------------------------------------------------------------------------- >>_date_.txt

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

For more details about Xcopy or Batch file you can visit this link:
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/xcopy.mspx?mfr=true

0 comments:

Post a Comment