Database Backup bat

Source: Internet
Author: User
Tags ftp client


Rem **************
Echo ===================================================== ================================>> backup. log
Echo start database backup time: % date % time %> Backup. Log
Rem backup database 2

Exp easyssh/easyssh @ 148 orcl file = D: \ backup \ dbbak \ vehes _ % Date :~ 0, 10%. dmp log = D: \ backup \ dbbak \ easyssh _ % Date :~ 8092. Log compress = n buffer = 10000 consistent = y direct = n constraints = y feedback = grants = y record = y indexes = y triggers = y rows = y


Rem ******** compressing Database Backup *************

Rem compression vehes Database Backup

C: \ progra ~ 1 \ WinRAR \ winrar.exe A-ibck D: \ backup \ rarbak \ easyssh _ % Date :~ 0, 102.16.rar D: \ backup \ dbbak \ easyssh _ % Date :~ 0, 10%. dmp D: \ backup \ dbbak \ easyssh _ % Date :~ 0, 10%. Log> Backup. Log


Rem *************


Del/f d: \ backup \ dbbak \ easyssh _ % Date :~ 0, 10%. dmp

Del/f d: \ backup \ dbbak \ easyssh _ % Date :~ 0, 10%. Log


Echo end database backup time: % date % time %> Backup. Log


Rem obtains the date of the previous 7 days.

Echo wscript. Echo dateadd ("D",-7, date)> % TMP % \ TMP. vbs

For/F "tokens = 1, 2, 3 delims =/-" % I in ('cscript/nologo % TMP % \ TMP. vbs ') do set Y = % I

For/F "tokens = 1, 2, 3 delims =/-" % I in ('cscript/nologo % TMP % \ TMP. vbs ') do set M = % J

For/F "tokens = 1, 2, 3 delims =/-" % I in ('cscript/nologo % TMP % \ TMP. vbs ') do set D = % K

If % m % LSS 9 set M = 0% M %

If % d % LSS 9 set D = 0% d %

Set deldate = % Y %-% m %-% d %

Rem deletes program backup seven days ago

Echo starts deleting D: \ backup \ rarbak \ * _1_deldate0000.rar at: % date % time %> Backup. Log

Del/f d: \ backup \ rarbak \ * _1_deldate0000.rar

Echo ends deleting D: \ backup \ rarbak \ * _1_deldate0000.rar at: % date % time %> Backup. Log


Rem starts to use the FTP client to connect and execute the script

@ Echo off

Echo open 10.131.98.80> backup_ftp.log

Echo XK> backup_ftp.log

Echo XK> backup_ftp.log

Echo send D: \ backup \ rarbak \ easyssh _ % Date :~ 0, 102.16.rar> backup_ftp.log

Echo bye> backup_ftp.log

FTP-S: backup_ftp.log

Rem Delete temporary files

Del/F backup_ftp.log
Rem **************

Echo ===================================================== ================================>> backup. log
Echo start database backup time: % date % time %> Backup. Log



Rem backup database 2

Exp vehes_admin/Oracle @ orcl92 file = D: \ backup \ dbbak \ vehes _ % Date :~ 0, 10%. dmp log = D: \ backup \ dbbak \ vehes _ % Date :~ 8092. Log compress = n buffer = 10000 consistent = y direct = n constraints = y feedback = grants = y record = y indexes = y triggers = y rows = y


Rem ******** compressing Database Backup *************

Rem compression vehes Database Backup

C: \ progra ~ 1 \ WinRAR \ winrar.exe A-ibck D: \ backup \ rarbak \ vehes _ % Date :~ 0, 102.16.rar D: \ backup \ dbbak \ vehes _ % Date :~ 0, 10%. dmp D: \ backup \ dbbak \ vehes _ % Date :~ 0, 10%. Log> Backup. Log


Rem *************


Del/f d: \ backup \ dbbak \ vehes _ % Date :~ 0, 10%. dmp

Del/f d: \ backup \ dbbak \ vehes _ % Date :~ 0, 10%. Log


Echo end database backup time: % date % time %> Backup. Log


Rem obtains the date of the previous 7 days.

Echo wscript. Echo dateadd ("D",-7, date)> % TMP % \ TMP. vbs

For/F "tokens = 1, 2, 3 delims =/-" % I in ('cscript/nologo % TMP % \ TMP. vbs ') do set Y = % I

For/F "tokens = 1, 2, 3 delims =/-" % I in ('cscript/nologo % TMP % \ TMP. vbs ') do set M = % J

For/F "tokens = 1, 2, 3 delims =/-" % I in ('cscript/nologo % TMP % \ TMP. vbs ') do set D = % K

If % m % LSS 9 set M = 0% M %

If % d % LSS 9 set D = 0% d %

Set deldate = % Y %-% m %-% d %

Rem deletes program backup seven days ago

Echo starts deleting D: \ backup \ rarbak \ * _1_deldate0000.rar at: % date % time %> Backup. Log

Del/f d: \ backup \ rarbak \ * _1_deldate0000.rar

Echo ends deleting D: \ backup \ rarbak \ * _1_deldate0000.rar at: % date % time %> Backup. Log


Rem starts to use the FTP client to connect and execute the script

@ Echo off

Echo open 127.0.0.1> backup_ftp.log

Echo XK> backup_ftp.log

Echo XK> backup_ftp.log

Echo send D: \ backup \ rarbak \ vehes _ % Date :~ 0, 102.16.rar> backup_ftp.log

Echo bye> backup_ftp.log

FTP-S: backup_ftp.log

Rem Delete temporary files

Del/F backup_ftp.log


Note: You must manually create two folders, D: \ backup \ dbbak and D: \ backup \ rarbak, on disk D ..

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.