写一个vbs文件,存储在【D:\bugzilla备份文件\bugzilla备份脚本\】路径下,名称为bugzilla_backup.vbs,内容为:
DIM obj
set obj=wscript.createObject("wscript.shell")
iAnswer=obj.Run("cmd.exe /C D:\bugzilla备份文件\bugzilla备份脚本\bugzilladump.bat", 0, TRUE)
写一个备分批处理bat文件,名称为bugzilladump.bat,存储在【D:\bugzilla备份文件\bugzilla备份脚本\】路径下,内容为:
@echo off
set bak_dir=D:\bugzilla_backup\
set db_type=mysql
set db_name=bugs
set db_user=bugs
set db_pwd=ilibo-024
set db_ipadress=192.168.1.122
set pweek=%date:~-1%
set bakfilename=%Date:~0,4%%Date:~5,2%%Date:~8,2%
if not exist %bak_dir% mkdir %bak_dir%
set filesuffix=sql
mysqldump -u%db_user% -p%db_pwd% -h%db_ipadress% %db_name% > %bak_dir%%bakfilename%.%filesuffix%
goto end
:end
set bak_dir=
set db_type=
set db_name=
set db_user=
set db_pwd=
set pweek=
set bakfilename=
set filesuffix=
设置开机自动执行备份:
cmd(开始-运行)-regedit-HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run-新建-字符串值,定义名称为Bugzilla_Backup,修改项值为【D:\bugzilla备份文件\bugzilla备份脚本\bugzilla_backup.vbs】即可,那么在每次开机时,系统都会自动备份bugs数据库中的数据到指定目录【D:\bugzilla_backup\】下。