Вы здесь

Скрипты на копирование

Смотрим хвост чего-нибудь

@echo off
cd "\Users\bipartners"
(
echo LLCMN:
echo.
tail.exe -10 D:\oracle\admin\scripts\backup_llcmn\hot_backup.log
echo.
echo LLCPRMN:
echo.
tail.exe -10 D:\oracle\admin\scripts\backup_llcprmn\hot_backup.log
) > tails.log
start notepad tails.log

смотрим логи

@start notepad D:\oracle\admin\scripts\backup_llcmn\hot_backup.log
@start notepad D:\oracle\admin\scripts\backup_llcprmn\hot_backup.log

Горячий бекап в архивлоге база

строка для запуска D:\oracle\admin\scripts\t1SVN\hot_backup.cmd FULL \\RUISTRAP05\Backup\t1SVN\FULL
файл hot_backup.cmd

@echo off

set CMDDIR=%~dp0
set CMDFIL=%~n0
set CMDFULL=%~dpnx0

set LOG_FILE=%CMDDIR%%CMDFIL%.log
set HIST_FILE=%CMDDIR%%CMDFIL%.log.all
set RMAN_FILE=%CMDDIR%%CMDFIL%.rman
set DONE_FILE=%CMDDIR%%CMDFIL%.done

set NLS_LANG=AMERICAN_CIS.CL8MSWIN1251
set ORACLE_SID=t1SVN
set SYS_CONN=/

set RECOVERY_WINDOW=6

set BACKUP_DIR=%2

if /i "%1" EQU "" goto full
if /i "%1" EQU "FULL" goto full
if /i "%1" EQU "LOGS" goto logs

goto usage

:full
set BACKUP_LEVEL=FULL

(
echo # backup level %BACKUP_LEVEL%
echo allocate channel for maintenance type disk;
echo crosscheck backup;
echo crosscheck archivelog all;
echo crosscheck copy;
echo delete noprompt expired backup;
echo delete noprompt expired archivelog all;
echo delete noprompt expired copy;
rem echo delete noprompt backup completed before 'sysdate-%RECOVERY_WINDOW%';
echo delete noprompt backup completed before 'trunc^(sysdate^)';
rem echo delete noprompt copy completed before 'sysdate-%RECOVERY_WINDOW%';
echo delete noprompt copy completed before 'trunc^(sysdate^)';
echo delete noprompt archivelog all
rem echo completed before 'trunc^(sysdate^)'
echo backed up 2 times to disk
echo ;
echo release channel;
echo run {
echo allocate channel c1 type disk;
echo allocate channel c2 type disk;
rem echo allocate channel c3 type disk;
rem echo allocate channel c4 type disk;
echo backup
rem echo incremental level 0
echo tag = 'Full Level 0'
echo format '%BACKUP_DIR%\%%T_%%d_FULL_%%u'
echo database
rem echo include current controlfile
rem echo plus archivelog delete all input
echo ;
echo backup archivelog all
echo not backed up 2 times
echo format '%BACKUP_DIR%\%%T_%%d_LOGS_%%u'
echo ;
echo backup spfile
echo tag = 'SPFILE'
echo format '%BACKUP_DIR%\%%T_%%d_SP_%%u'
echo ;
echo backup current controlfile
echo tag = 'CONTROLFILE for FULL backup'
echo format '%BACKUP_DIR%\%%T_%%d_CTL_%%u'
echo ;
rem echo release channel c4;
rem echo release channel c3;
echo release channel c2;
echo release channel c1;
echo }
echo host "echo done ^> %DONE_FILE%";
echo exit;
) > %RMAN_FILE%

goto rman

:logs
set BACKUP_LEVEL=LOGS

(
echo # backup level %BACKUP_LEVEL%
echo allocate channel for maintenance type disk;
echo crosscheck archivelog all;
echo delete noprompt expired archivelog all;
echo delete noprompt archivelog all
echo completed before 'trunc^(sysdate^)'
echo backed up 2 times to disk
echo ;
echo release channel;
echo run {
rem echo allocate channel c1 type disk;
rem echo allocate channel c2 type disk;
rem echo allocate channel c3 type disk;
echo allocate channel c4 type disk;
echo backup archivelog all
echo not backed up 2 times
echo format '%BACKUP_DIR%\%%T_%%d_LOGS_%%u'
echo ;
echo backup current controlfile
echo tag = 'CONTROLFILE for LOGS backup'
echo format '%BACKUP_DIR%\%%T_%%d_CTL_%%u'
echo ;
echo release channel c4;
rem echo release channel c3;
rem echo release channel c2;
rem echo release channel c1;
echo }
echo host "echo done ^> %DONE_FILE%";
echo exit;
) > %RMAN_FILE%

:rman

(
echo.
echo ===== Begin of backup =====
echo %DATE% %TIME%
echo BACKUP_DIR=%BACKUP_DIR%
echo RMAN_FILE=%RMAN_FILE%
) > %LOG_FILE%

if exist %DONE_FILE% del /f %DONE_FILE% >> %LOG_FILE%

rem -----------------------------------------
rem Checking accessability of target folder's
rem -----------------------------------------

echo copy "%CMDFULL%" %BACKUP_DIR% >> %LOG_FILE%
copy "%CMDFULL%" %BACKUP_DIR%

if %ERRORLEVEL% EQU 0 (
rman target %SYS_CONN% nocatalog cmdfile=%RMAN_FILE% >> %LOG_FILE%
echo RMAN errorlevel=%ERRORLEVEL% >> %LOG_FILE%
) else (
echo Target folder "%BACKUP_DIR%" is not accessible! ^(err=%ERRORLEVEL%^) >> %LOG_FILE%
echo BACKUP_FAILED_check_log >> %LOG_FILE%
)

goto end

:usage

echo.
echo Invalid argument "%1"
echo Usage values:
echo FULL - for performing full backup
echo LOGS - for performing archived logs backup
echo.
echo invalid argument "%1" >> %LOG_FILE%

:end

(
echo errorlevel=%ERRORLEVEL%
if %ERRORLEVEL% NEQ 0 (
echo BACKUP_FAILED_check_log )
echo %DATE% %TIME%
echo ===== End of backup =====
echo.
) >> %LOG_FILE%

type %LOG_FILE% >> %HIST_FILE%
copy %HIST_FILE% %BACKUP_DIR%

файл hoy_backup.rmn

# backup level LOGS
allocate channel for maintenance type disk;
crosscheck archivelog all;
delete noprompt expired archivelog all;
delete noprompt archivelog all
completed before 'trunc(sysdate)'
backed up 2 times to disk
;
release channel;
run {
allocate channel c4 type disk;
backup archivelog all
not backed up 2 times
format '\\RUISTRAP05\Backup\t1SVN\ARCH\%T_%d_LOGS_%u'
;
backup current controlfile
tag = 'CONTROLFILE for LOGS backup'
format '\\RUISTRAP05\Backup\t1SVN\ARCH\%T_%d_CTL_%u'
;
release channel c4;
}
host "echo done ^> D:\oracle\admin\scripts\t1SVN\hot_backup.done";
exit;

#################### горячий бекап база не в архивлоге

@echo off

set CMDDIR=%~dp0
set CMDFIL=%~n0
set CMDFULL=%~dpnx0

set LOG_FILE=%CMDDIR%%CMDFIL%.log
set HIST_FILE=%CMDDIR%%CMDFIL%.log.all
set RMAN_FILE=%CMDDIR%%CMDFIL%.rman
set DONE_FILE=%CMDDIR%%CMDFIL%.done

set BACKUP_DIR=\\10.0.1.25\tele2backup
set RMAN_FILE=C:\TELE2\backups\cold_backup.rman

set NLS_LANG=AMERICAN_CIS.CL8MSWIN1251
set ORACLE_SID=TELE2
set SYS_CONN=/

set RECOVERY_WINDOW=6

#set BACKUP_DIR=%2

(
echo # backup full
echo shutdown immediate;
echo startup nomount;
echo sql 'alter database mount';
echo allocate channel for maintenance type disk;
echo crosscheck backup;
echo crosscheck copy;
echo delete noprompt expired backup;
echo delete noprompt expired copy;
echo delete noprompt backup completed before 'sysdate-%RECOVERY_WINDOW%';
echo delete noprompt copy completed before 'sysdate-%RECOVERY_WINDOW%';
echo release channel;
echo run {
echo allocate channel c1 type disk;
echo allocate channel c2 type disk;
echo allocate channel c3 type disk;
echo allocate channel c4 type disk;
echo backup
echo format '%BACKUP_DIR%\%%T_%%d_COLD_%%u'
echo database
echo noexclude
echo ;
echo backup spfile
echo tag = 'SPFILE'
echo format '%BACKUP_DIR%\%%T_%%d_SP_%%u'
echo ;
echo backup current controlfile
echo tag = 'CONTROLFILE for FULL backup'
echo format '%BACKUP_DIR%\%%T_%%d_CTL_%%u'
echo ;
echo release channel c4;
echo release channel c3;
echo release channel c2;
echo release channel c1;
echo sql 'alter database open';
echo }
echo host "echo done ^> %DONE_FILE%";
echo exit;
) > %RMAN_FILE%

(
echo.
echo ===== Begin of backup =====
echo %DATE% %TIME%
echo BACKUP_DIR=%BACKUP_DIR%
echo RMAN_FILE=%RMAN_FILE%
) > %LOG_FILE%

if exist %DONE_FILE% del /f %DONE_FILE% >> %LOG_FILE%

rem -----------------------------------------
rem Checking accessability of target folder's
rem -----------------------------------------

copy "%CMDFULL%" %BACKUP_DIR% >> %LOG_FILE%
copy "%CMDFULL%" %BACKUP_DIR%

if %ERRORLEVEL% EQU 0 (
rman target %SYS_CONN% nocatalog cmdfile=%RMAN_FILE% >> %LOG_FILE%
echo RMAN errorlevel=%ERRORLEVEL% >> %LOG_FILE%
) else (
echo Target folder "%BACKUP_DIR%" is not accessible! ^(err=%ERRORLEVEL%^) >> %LOG_FILE%
echo BACKUP_FAILED_check_log >> %LOG_FILE%
)

(
echo errorlevel=%ERRORLEVEL%
if %ERRORLEVEL% NEQ 0 (
echo BACKUP_FAILED_check_log )
echo %DATE% %TIME%
echo ===== End of backup =====
echo.
) >> %LOG_FILE%

type %LOG_FILE% >> %HIST_FILE%
copy %HIST_FILE% %BACKUP_DIR%

############################## вот такой вот файлик дает

# backup full
shutdown immediate;
startup nomount;
sql 'alter database mount';
allocate channel for maintenance type disk;
crosscheck backup;
crosscheck copy;
delete noprompt expired backup;
delete noprompt expired copy;
delete noprompt backup completed before 'sysdate-6';
delete noprompt copy completed before 'sysdate-6';
release channel;
run {
allocate channel c1 type disk;
allocate channel c2 type disk;
backup
format '\%T_%d_COLDL_fs1_%u'
database
noexclude
;
backup spfile
tag = 'SPFILE'
format '\%T_%d_SP_%u'
;
backup current controlfile
tag = 'CONTROLFILE for FULL backup'
format '\%T_%d_CTL_%u'
;
release channel c4;
release channel c3;
release channel c2;
release channel c1;
sql 'alter database open';
}
host "echo done ^> C:\TELE2\backups\tele2_cold_backup.done";
exit;

Menu_os: 
source: 

где стырено, там стырено.

Post new comment

Filtered HTML

  • Адреса страниц и электронной почты автоматически преобразуются в ссылки.
  • Разрешённые HTML-теги: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Строки и параграфы переносятся автоматически.

Plain text

  • HTML-теги не обрабатываются и показываются как обычный текст
  • Адреса страниц и электронной почты автоматически преобразуются в ссылки.
  • Строки и параграфы переносятся автоматически.
CAPTCHA
Этот вопрос задается для того, чтобы выяснить, являетесь ли Вы человеком или представляете из себя автоматическую спам-рассылку.
2 + 3 =
Решите эту простую математическую задачу и введите результат. Например, для 1+3, введите 4.