Mysql 定时自动备份到指定位置
1 set h=%time:~0,2%
2 set h=%h: =0%
3 set bak_filename=%date:~0,4%%date:~5,2%%date:~8,2%%h%%time:~3,2%%time:~6,2%
4 @ECHO %tm%
5 SET bkupdir=F:Databackup
6 SET mysqldir=F:WEBupupwMySQL
7 path=%path:;F:WEBupupwMySQLin;%
8 SET dbname=mysql
9 SET dbuser=root
10 SET dbpassword=root
11 SET CharacterSet=utf8
12 @ECHO Beginning backup of %dbname%...
13 mysqldump -u%dbuser% -p%dbpassword% mysql>%bkupdir%\%dbname%%bak_filename%.sql
14 @ECHO Done! New file: %bkupdir%\%dbname%-%bak_filename%.sql
把以上代码保存为.bat 文件然后加入windows计划任务就能实现windows下mysql每日定时备份了,根据以上代码,相信你也能写出在linux下定时执行PHP的代码了,我在这里就不写了,如有需求可留言。