Backup bat:
@ Set destfile = ICBC_mysql % date :~ 0, 4% % date :~ 5, 2% % date :~ 8, 2%. SQL
@ Set ftpfile = ICBC_mysql % date :~ 0, 4% % date :~ 5, 2% % date :~ 8, 22.16.rar
@ Echo: date: % date :~ 0, 4% % date :~ 5, 2% % date :~ 8, 2%
@ Echo backup file: % destfile %
@ F:
@ Cd \ bak_mis
@ Echo backing up ......
@ "C: \ Program Files \ MySQL Server 5.1 \ bin \ mysqldump.exe"-opt-uroot-p1234-P3306-all-databases> % destfile %
@ Echo start compression
@ "C: \ Program Files \ WinRAR \ Rar.exe" a-ed % ftpfile % destfile %
@ Del F: \ bak_mis \ % destfile %
@ Echo: The backup is complete and is being backed up to remote FTP ......
@ Echo user nmcx 185700> ftp.txt
@ Echo bin> ftp.txt
@ Echo put % ftpfile %> ftp.txt
@ Echo bye> ftp.txt
@ Ftp-I-n XXXX. XXXX <ftp.txt
@ Echo: The backup is successfully completed.
Restore bat:
@ Set destfile = ICBC_mysql % date :~ 0, 4% % date :~ 5, 2% % date :~ 8, 2%. SQL
@ Set ftpfile = ICBC_mysql % date :~ 0, 4% % date :~ 5, 2% % date :~ 8, 22.16.rar
@ Echo: date: % date :~ 0, 4% % date :~ 5, 2% % date :~ 8, 2%
@ Echo restore File: % destfile %
@ D:
@ Cd \ DB_bak
@ Echo is downloading files from remote FTP ......
@ Echo user nmcx 185700> ftp.txt
@ Echo bin> ftp.txt
@ Echo get % ftpfile %> ftp.txt
@ Echo bye> ftp.txt
@ Ftp-I-n XXXX. XXXX <ftp.txt
@ Echo start decompression
@ "C: \ Program Files \ WinRAR \ UnRAR.exe" e % ftpfile %
@ Echo is restoring the database ......
@ "D: \ MySQL Server 5.1 \ bin \ mysql.exe"-uroot-p1234-P3306 <D: \ DB_bak \ % destfile %
@ Del % destfile %
@ Echo: restored successfully
Note: (marked in red, the ftp user name, password, and ftp address respectively)
(In the purple part, the username, password, and port of the MySQL database respectively)