1. Tạo script file backup trên localhost
a. Window server:
Dùng notepad tạo file *.bat với nội dung sau:
set DATET=%date:~10,4%_%date:~4,2%_%date:~7,2%
"d:\xampp\mysql\bin\mysqldump" --host="localhost" --user="root" --password="" DATABASE > "D:\"backup_database_%DATET%.sql
#pause
Sau đó, tạo Schedule Tasks trong Control Panel
Note:
Year (YYYY) | %date:~10,4% or %date:~12,2% (2 digits: YY) |
---|---|
Month (MM) | %date:~4,2% |
Day (DD) | %date:~7,2% |
Hour (HH) | %time:~0,2% |
Minute (MM) | %time:~3,2% |
Second (SS) | %time:~6,2% |
Milisecond | %time:~9,2% |
2. Linux server:
Từ command line, edit crontab trên linux
# crontab -e
15 2 * * * root mysqldump -u root -pPASSWORD --all-databases | gzip > /backup/database_`data ' %m-%d-%Y'`.sql.gz
Note: Các option cho * * * * *
Field | Meaning |
---|---|
1 | Minute (0-59) |
2 | Hour (2-24) |
3 | Day of month (1-31) |
4 | Month (1-12, Jan, Feb, etc) |
5 | Day of week (0-6) 0 = Sunday, 1 = Monday etc or Sun, Mon, etc) |
6 | User that the command will run as |
7 | Command to execute |
2. Dùng Mysql Administrator
Dùng Mysql Administrator trong bộ Mysql GUI Tools (Download tại http://dev.mysql.com/downloads/gui-tools/5.0.html)
Mysql Administrator |
Tab Backup - Schedule |
No comments:
Post a Comment