The windows server automatically backs up the of batch of tasks
- 2020-05-07 20:44:35
- OfStack
Listing 1 integration commands
Function: automatically backup database and create backup folder by date.
@echo off
echo Perform backup tasks
echo Stopping database...
echo Stopping the website database...
net stop MySQL
echo Perform a backup database
xcopy "D:\MySQL\data\*.*" D:\mysqlbak\webbak%date:~0,10%\ /e /y /c
net start MySQL
echo Starting web database...
echo Exit the backup task
echo .
exit
Apart:
Stop database command
net stop MySQL
Copy database files
D:\MySQL\data\ store directories for databases
D:\mysqlbak\webbak is the database backup directory
%date:~0,10% create a directory for the current backup date
xcopy "D:\MySQL\data\*.*" D:\mysqlbak\webbak%date:~0,10%\ /e /y /c
Start database
net start MySQL
The integration command listing 2
Features: automatically backup database and date rar encrypted packaging (password 123456).
@echo off
echo Perform backup tasks
echo Stopping database...
echo Stopping the website database...
net stop MySQL
echo Perform a backup database
xcopy "D:\host\mysql\data\*.*" E:\wwwroot\Default\webmysql\ /e /y /c
net start MySQL
echo Starting web database...
echo Packing the website 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 packaging
echo Delete replication database
del /s /q E:\wwwroot\Default\webmysql\*
echo Exit the backup task
echo .
exit
Apart:
The above repeat command is not repeated
Package and encrypt
C:\Program Files\WinRAR\WinRAR
123456 is the compressed packet encryption password
E:\wwwroot\Default\ is the directory packed into
%date:~0,10%-WEBDATA.rar is the compressed file name, for example, today is 2012-12-27, the name is 2012-12-27-WEBDATA.rar
"C:\Program Files\WinRAR\WinRAR.exe" a -r -ibck -p123456 -y E:\wwwroot\Default\%date:~0,10%-WEBDATA.rar E:\wwwroot\Default\webmysql\*.*
Delete copied data
E:\wwwroot\Default\webmysql\* is the backup directory, to facilitate the next backup 1 must be deleted. It's easy to repeat.
del /s /q E:\wwwroot\Default\webmysql\*
backup task download
description:
Command download from the web site to the specified directory
wget http:// Backup file WEB address /MySQLDATA-%date:~0,10%.rar -P E:\ The data backup \%date:~0,10%
Download address: wget http: / / pan baidu. com/share/link? shareid = 4576 & uk = 956587458
On C: \ Windows \ System32
Note: you can also download with other tools. This method is not recommended for large files. Not bad for small files.
adds the automatic task
Open the task panel - > Task plan
Double click add task plan
Next step browse to the CMD you created.
Customize the name of the task, if it is a database, it is recommended to backup once a day. You can set it up for 1 week if you have a website file.
The next step is to set the time. It is recommended to set the time around 2-3 points.
The next step is to complete the task creation by entering the managed account and password.