Oracle automatic backup script in windows, automatically retained for 7 days

Source: Internet
Author: User

Windows oracle automatic backup script, automatically retain 7 days Bat code www.2cto.com @ echo off set backhome = backup set year = % date :~ 0, 4% set month = % date :~ 5, 2% set day = % date :~ 8, 2% set mydate = % year % month % day % set hhmmss = % time :~ 0, 2% % time :~ 3,2% % time :~ 6, 2% if "% hhmmss :~ 0% % "=" "set hhmmss = time :~ 1, 1% % time :~ 3,2% % time :~ 6, 2% mkdir d: \ % backhome % \ % mydate % echo --------------------------------------------------> d: \ % backhome % \ % mydate % \ log.txt echo start backup at % mydate % _ % hhmmss %> d: \ % backhome % \ % mydate % \ log.txt echo ----------------------------------------------> d: \ % backhome % \ % mydate % \ log.txt exp andacms/andacms @ OA file = d: \ % backhome % \ % mydate % \ andacms _ % mydate %. dmp owner = andacms BUFFER = 512000000 2> d: \ % backhom E % \ % mydate % \ log.txt echo --------------------------------------------------> d: \ % backhome % \ % mydate % \ log.txt set endyear = % date :~ 0, 4% set endmonth = % date :~ 5, 2% set endday = % date :~ 8, 2% set enddate = % endyear % endmonth % endday % set endhhmmss = % time :~ 0, 2% % time :~ 3,2% % time :~ 6, 2% if "% endhhmmss :~ 0% % "=" "set endhhmmss = time :~ 1, 1% % time :~ 3,2% % time :~ 6, 2% echo backup finished at % enddate % _ % endhhmmss %> d: \ % backhome % \ % mydate % \ log.txt echo ----------------------------------------------> d: \ % backhome % \ % mydate % \ log.txt rem calculates the date set DaysAgo = 3 rem before the specified number of days. Assume that the system date format is yyyymmdd call: DateToDays % date :~ 0, 4% % date :~ 5, 2% % date :~ 8, 2% PassDays set/a PassDays-= % DaysAgo % call: DaysToDate % PassDays % DstYear DstMonth DstDay set DstDate = % DstYear % DstMonth % DstDay % if exist d: \ % backhome % \ % DstDate % (echo deletes data from % DaysAgo % days ago: % DstDate %> d: \ % backhome % \ % mydate % \ log.txt rmdir/s/q d: \ % backhome % \ % DstDate %) goto: eof: dateToDays % yy % mm % dd % days setlocal ENABLEEXTENSIONS set yy = % 1 & set mm = % 2 & set dd = % 3 if 1% yy % LSS 200 if 1% yy % LSS 170 (set yy = 20% yy %) else (set yy = 19% yy %) set/a dd = 100% dd % 100, mm = 100% mm % 100 set/a z = 14-mm, z/= 12, y = yy + 4800-z, m = mm + 12 * z-3, j = 153 * m + 2 set/a j = j/5 + dd + y * 365 + y/4-y/100 + y/400-2472633 endlocal & set % 4 = % j % & goto: EOF: DaysToDate % days % yy mm dd setlocal ENABLEEXTENSIONS set/a = % 1 + 2472632, B = 4 * a + 3, B/= 146097, c =-B * 146097, c/= 4, c + = a set/a d = 4 * c + 3, d/= 1461, e =-1461 * d, e/= 4, e + = c, m = 5 * e + 2, m/= 153, dd = 153 * m + 2, dd/= 5 set/a dd =-dd + e + 1, mm =-m/10, mm * = 12, mm + = m + 3, yy = B * 100 + d-4800 + m/10 (if % mm % LSS 10 set mm = 0% mm %) & (if % dd % LSS 10 set dd = 0% dd %) endlocal & set % 2 = % yy % & set % 3 = % mm % & set % 4 = % dd % & goto: EOF

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.