For Windows Hosts
====================
Hypothetical environment:
MySQL installation path: C: MySQL
Forum Database Name: bbs
MySQL root Password 123456
Database Backup destination: D: db_backup
Program code
@ Echo off
C: MySQLinmysqladmin-u root -- password = 123456 shutdown
C: MySQLinmysqldump -- opt-u root -- password = 123456 bbs> D: db_backupbs. SQL
C: MySQLinmysqld-nt
Save the preceding code as backup_db.bat.
Then, run the script periodically using the "scheduled task" of Windows.
You can also use PHP to complete the following steps:
Make it possible for MYSQL to implement automatic backup!
1. Edit the code below and save it as backup.php. If you want to compress the code, you can copy rar.exe:
If ($ argc! = 2 | in_array ($ argv [1], array (-- help ,-?))) {
?>
Backup Ver 0.01, for Win95/Win98/WinNT/Win2000/WinXP on i32
Copyright (C) 2000 ptker All rights reserved.
This is free software, and you are welcome to modify and redistribute it
Under the GPL license
PHP Shell script for the backup MySQL database.
Usage:
Can be database name you wowould like to backup.
With the -- help, or -? Options, you can get this help and exit.
} Else {
$ Dbname = $ argv [1];
$ Dump_tool = "c: \ mysql \ bin \ mysqldump ";
$ Rar_tool = "d: \ php4 \ rar ";
@ Exec ("$ dump_tool -- opt-u user-ppassword $ dbname>./$ dbname. SQL ");
@ Exec ("$ rar_tool a-ag_yyyy_mm_dd_hh_mm mongodbname.rar $ dbname. SQL ");
@ Unlink ("$ dbname. SQL ");
Echo "Backup complete! ";
}
?>
2. Add a task scheduler and enter the following command in step (2:
D: php4php.exe-q D: php4ackup. php databasename
3. Set the time to run the task once every day and then run the task.
4. An rarfile consisting of the Database Name and current time will be generated in the d: php4 directory.