Timed Backups of Oracle databases: Exporting compression collations

Source: Internet
Author: User
Tags mkdir rar

http://skzr-org.javaeye.com/blog/811491

Goal: Timed export: Use Scheduled tasks to automatically compress: using the command line RAR automatic monthly storage: using cmd

Code:

  CMD code @echo   must go to the specified path, otherwise it will run abnormally    @set  bk_path=g:/database_bak    @set  rar_ Path=d:/winrar    @set  owner=erp_beijing_exp    @set  userid=%owner%/erp_beijing_ Exp@dbsvr    @echo  on    @CLS    @echo   Welcome to use the Automatic library program    @echo   Start execution    @echo   Access directory:  %bk_path%    @%bk_path:~0,2%    @cd  %bk_path%     CD    set the_month=%date:~0,4%-%date:~5,2%    set the_date=%the_month%-%date: ~8,2%    echo %the_date%    set my_hour=%time:~0,2%    if  "%time:~0,1%" = = " "  set my_hour=0%time:~1,1%       set my_date=%the_date%_%my_hour%-% time:~3,2%-%time:~6,2%    @echo   Current time%the_date%    @set  filename=%my_date%_%username%    exp.exe userid= "%userid%"  owner=%owner% file=%filename%.dmP log=%filename%-exp.log    "%rar_path%/rar"  a -k -t -s -m5 -mc63 : 128t+ -mdg -df %filename%.rar %filename%*.*    mkdir %bk_path%/%the_month%    move %bk_path%/*%the_date%*.* %bk_path%/%the_month%    exit  

@echo must enter the specified path, otherwise it will not run properly
@set bk_path=g:/database_bak
@set rar_path=d:/winrar
@set owner=erp_beijing_ Exp
@set userid=%owner%/erp_beijing_exp@dbsvr
@echo on
@CLS
@echo Welcome to the automatic library
@echo start Execution
@ echo into directory:%bk_path%
@%bk_path:~0,2%
@cd%bk_path%
cd
set the_month=%date:~0,4%-%date:~5,2%
set the_date=%the_month%-%date:~8,2%
echo%the_date%
set my_hour=%time:~0,2%
if "%time:~0,1%" = = "" Set my_hour=0%time:~1,1%

set my_date=%the_date%_%my_hour%-%time:~3,2%-%time:~6,2%
@echo Current Time%the_ date%
@set filename=%my_date%_%username%
exp.exe userid= "%userid%" owner=%owner% file=%filename%.dmp log= %filename%-exp.log
"%rar_path%/rar" a-k-t-s-m5-mc63:128t+-mdg-df%filename%.rar%filename%*.* MKDIR%bk_
path%/%the_month% move
%bk_path%/*%the_date%*.*%bk_path%/%the_month%
exit

Problems encountered and resolved:

File name: The hour before 10 o'clock for "X" has a space to cause file name problems, solve the set my_hour=%time:~0,2% cmd code if "%time:~0,1%" "" Set my_hour=0%time:~1,1%

If "%time:~0,1%" = "" Set my_hour=0%time:~1,1%
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.