1、MySQL备份还原
1.备份
mysqldump -uroot -p123456 itool > itooldb_back20200408.sql
2.还原
mysql -uroot -p123456 itool < itooldb_back20200408.sql #将备份导入 itool 数据库。
2、定时任务路径:/etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
# For details see man 4 crontabs
# Example of job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed
0 1 * * * root /root/shell/itoolbackup.sh
2、定时执行的shell(/root/shell/itoolbackup.sh)
filedate=`date +%Y%m%d`
/usr/bin/mysqldump -uroot -p123456 itool > /root/db_back/itooldb_back$filedate.sql