Windows Server Automatic backup task (batch) _win server

Source: Internet
Author: User
Tags rar

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

Copy Code code as follows:

@echo off
Echo Performs a backup task
ECHO is stopping the database ...
Echo is stopping the Web site database ...
net stop MySQL
Echo performs backup database
xcopy "D:\mysql\data\*.*" d:\mysqlbak\webbak%date:~0,10%\/e/y/C
net start MySQL
Echo is starting the Web site database ...
Echo Quits backup task
Echo.
Exit

Dismantling:
Stop Database command
Copy Code code as follows:

net stop MySQL

Copy database files
D:\MySQL\data\ for database storage directory
D:\mysqlbak\webbak Backup directory for database
%date:~0,10% Create a directory for the current backup date
Copy Code code as follows:

xcopy "D:\mysql\data\*.*" d:\mysqlbak\webbak%date:~0,10%\/e/y/C

Start the database
Copy Code code as follows:

net start MySQL

Integration Command List 2
Function: Automatically back up the database and date RAR encryption Package (password is 123456).
Copy Code code as follows:

@echo off
Echo Performs a backup task
ECHO is stopping the database ...
Echo is stopping the Web site database ...
net stop MySQL
Echo performs backup database
xcopy "D:\host\mysql\data\*.*" E:\wwwroot\Default\webmysql\/e/y/C
net start MySQL
Echo is starting the Web site database ...
Echo is packing the Web site database ...
"C:\Program files\winrar\winrar.exe" A-r-ibck-p123456-y e:\wwwroot\default\%date:~0,10%-webdata.rar E:\wwwroot\ Default\webmysql\*.*
echo Exit RAR Package
echo Delete replication database
DEL/S/q e:\wwwroot\default\webmysql\*
Echo Quits backup task
Echo.
Exit

Dismantling:
The above repeated commands do not repeat the instructions
Packaging and encrypting
C:\Program files\winrar\winrar.exe install directory for WinRAR compression program
123456 Encrypt password for compressed package
E:\wwwroot\Default\ to the directory to be packaged
%date:~0,10%-webdata.rar is a compressed filename, for example today is 2012-12-27 name is 2012-12-27-webdata.rar
Copy Code code as follows:

"C:\Program files\winrar\winrar.exe" A-r-ibck-p123456-y e:\wwwroot\default\%date:~0,10%-webdata.rar E:\wwwroot\ Default\webmysql\*.*

Delete copy data
e:\wwwroot\default\webmysql\* is a backup directory and must be removed for easy next backup. Otherwise it's easy to repeat.
Copy Code code as follows:

DEL/S/q e:\wwwroot\default\webmysql\*


Backup Task Downloads
Description
Download a command from a Web site to a specified directory
Copy Code code as follows:

wget http://backup file Web address/mysqldata-%date:~0,10%.rar-p e:\ data backup \%date:~0,10%

wget Download Address: http://pan.baidu.com/share/link?shareid=4576&uk=956587458
Put it in the C:\Windows\System32.
Note: You can also use other tools to download, if the large file is not recommended in this way. It's fine for small files.

add an automatic task
Open Task Panel-> Task Scheduler
Double-click Add Task Schedule
Next browse to the cmd you created.
The name of the custom task, which is recommended to be backed up once a day if it is a database. If the site file can be set for a week.
The next set of time, the recommended setting of about 2-3 points.
Next, enter the managed account number and password to complete the task creation.

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.