Windows Server Automatic Backup Task (batch processing)

Source: Internet
Author: User

Integrated Command List 1
Function: automatically backs up the database and creates a backup folder by date.

Copy codeThe Code is as follows: @ echo off
Echo executes the Backup Task
Echo is stopping the database...
Echo is stopping the website database...
Net stop MySQL
Echo back up the database
Xcopy "D: \ MySQL \ data \ *. *" D: \ mysqlbak \ webbak % date :~ 0, 10% \/e/y/c
Net start MySQL
Echo is starting the website database...
Echo exits the Backup Task
Echo.
Exit

Disassembling:
Stop database commandsCopy codeThe Code is as follows: net stop MySQL

Copy database files
D: \ MySQL \ data \ stores the database directory
D: \ mysqlbak \ webbak is the Database Backup Directory
% Date :~ % Is the directory created on the current backup dateCopy codeThe Code is as follows: xcopy "D: \ MySQL \ data \ *. *" D: \ mysqlbak \ webbak % date :~ 0, 10% \/e/y/c

Start DatabaseCopy codeThe Code is as follows: net start MySQL

List of Integrated commands 2
Function: automatically backs up the database and encrypts and packs the database with a date (the password is 123456 ).Copy codeThe Code is as follows: @ echo off
Echo executes the Backup Task
Echo is stopping the database...
Echo is stopping the website database...
Net stop MySQL
Echo back up the database
Xcopy "D: \ host \ mysql \ data \ *. *" E: \ wwwroot \ Default \ webmysql \/e/y/c
Net start MySQL
Echo is starting the website database...
Echo is packing the website database...
"C: \ Program Files \ WinRAR \ WinRAR.exe" a-r-ibck-p123456-y E: \ wwwroot \ Default \ % date :~ 0, 102.16-webdata.rar E: \ wwwroot \ Default \ webmysql \*.*
Echo exit RAR package
Echo deletes a Replicated Database
Del/s/q E: \ wwwroot \ Default \ webmysql \*
Echo exits the Backup Task
Echo.
Exit

Disassembling:
The preceding repeated commands are not repeated.
Package and Encrypt
C: \ Program Files \ WinRAR \ WinRAR.exe is the installation directory of the winrar compression Program.
123456 encrypt the compressed package Password
E: \ wwwroot \ Default \ is the package directory
% Date :~ 0, 10 bytes -webdata.rar is the compressed file name. For example, today is 2012-12-27, And the name is 2012-12-27-WEBDATA.rar.Copy codeThe Code is as follows: "C: \ Program Files \ WinRAR \ WinRAR.exe" a-r-ibck-p123456-y E: \ wwwroot \ Default \ % date :~ 0, 102.16-webdata.rar E: \ wwwroot \ Default \ webmysql \*.*

Delete copy data
E: \ wwwroot \ Default \ webmysql \ * is the Backup Directory, which must be deleted next time. Otherwise, it is easy to repeat.Copy codeThe Code is as follows: del/s/q E: \ wwwroot \ Default \ webmysql \*

Backup Task download
Note:
Download commands from the website to the specified directoryCopy codeThe Code is as follows: wget http: // WEB address of the backup file/MySQLDATA-% date :~ 0, 102.16.rar-p e: \ data backup \ % date :~ 0, 10%

Wget: http://pan.baidu.com/share/link? Consumer id = 4576 & uk = 956587458
In C: \ Windows \ System32
Note: You can also use other tools to download large files. This method is not recommended if large files are used. It is okay for small files.

Add automatic task
Open the task panel-> Task Plan
Double-click "add Task Scheduler"
Next, browse to the CMD you created.
Name of the custom task. If it is a database, we recommend that you back up the task once a day. You can set the website file to one week.
Next, we recommend that you set the time around 2-3.
Next, enter the managed account and password to create the task.

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.