제가 사용하는 스크립트 입니다.
설명을 붙이 자면 날짜와 시간을 받아서 화일명을 바꾸는 배치화일을 만들고
At 이라는 스케줄러를 이용하여 백업을 합니다.
물론 Exp 를 이용하여 벡업을 하고 있습니다.
참고로 Doff 라는 프로그램을 이용하며 날짜을 넘겨 받을수 있도록 합니다.(하단 소스 참고)
============================================================================
# at 04:00 /every:M,T,W,Th,F,S,Su E:ORACLE_BKscriptfullbackup.bat
at 03:00 /every:M,T,W,Th,F,S,Su E:ORACLE_BKscriptuserdump.bat
at 04:00 /every:M,W,F,Su E:ORACLE_BKscriptfullbackup.bat
=============================================================================
================================ Full backup.bat===============================
@echo off
for /f "tokens=1-3 delims=/ " %%a in ('doff mm/dd/yyyy -1') do ( set mm=%%a set dd=%%b set yyyy=%%c)
e: cd E:ORACLE_BK
rename fullbackup.dmp fullbackup-%yyyy%%mm%%dd%.dmp
exp system/systempass file='E:ORACLE_BKfullbackup.dmp' full=y
===================================================================
================================ userdump.bat===============================
@echo off
for /f "tokens=1-3 delims=/ " %%a in ('doff mm/dd/yyyy -1') do ( set mm=%%a set dd=%%b set yyyy=%%c)
e: cd E:ORACLE_BK
rename user.dmp user-%yyyy%%mm%%dd%.dmp
exp userid=user/userpass file='E:ORACLE_BKuser.dmp'
===================================================================
=============================doff.exe ========================================
* ** doff - prints a formatted date string offset by a specified time interval ** ** File: doff.c ** Author: John Fitzgibbon (fitz@jfitz.com http://www.jfitz.com) ** Version: 1.0 ** Date: 11/08/1999 ** ** This program and code is FREEWARE. ** ** Command line format: doff [format_str [offset_str [exclude_format_str]]] ** doff -h to display help. ** ** Revision History ** 11/08/1999 1.0 Original Version */
char helpstr[] = "doff - Prints a formatted date string offset by a specified time intervaln" "syntax is: doff [format_str [offset_str [exclude_format_str]]]n" " or: doff -h (displays this help screen)n" "n" "format_str, (case sensitive), may include any of the following:n" " yyyy - replaced by four digit year in output stringn" " yy - replaced by two digit year in output stringn" " mm - replaced by month (1 - 12) in output stringn" " dd - replaced by day (1 - 31) in output stringn" " hh - replaced by hour (0 - 23) in output stringn" " mi - replaced by minute (0 - 59) in output stringn" " ss - replaced by second (0 - 59) in output string (leap seconds = 59)n" "Other characters in format_str are returned as-isn" "n" "offset_str, (case sensitive), is specified as [+/-]n[smhd]n" " "n" is the offset valuen" " offset qualifiers are: s = seconds, m = minutes, h = hours, d = daysn" "n" "exclude_format_str has the same format as format str.n" "Patterns in exclude_format_str that would normally be translated are ignored.n" "For example, including "ss" in exclude_format_str means "ss" will appearn" "untranslated in the output string.n" "n" "Default offset value is zero, default offset qualifier is daysn" "Bad offset values default to zero, bad offset qualifiers default to daysn" "Note: -10xd will evaluate to "10 days ago", (because atoi("-10x") = -10)n" " but -x10d will evaluate to "now", (because atoi("-x10") = 0)n" "n" "When both format_str and offset_str are omitted the output format is:n" "yyyymmddhhmissn";
#include <stdlib.h> #include <stdio.h> #include <string.h> #include <time.h>
int main (int argc, char * argv[]) { time_t etime; struct tm * stime; char dstr[15]; char * cp;
if ((argc > 1) && !strncmp(argv[1],"-h",2)) { puts(helpstr); exit(0); } time(&etime); if (argc > 2) { if ((cp = strstr(argv[2],"s")) != NULL) // offset seconds { *cp = '
|