标签:mysql discuz wordpress already
mysqldump() { echo “开始进行 $mysql_dbname1 $mysql_dbname2 备份…” if [ -d "${backdir}/${date}" ];then echo “Mysql Database dir already exists.” exit 1 else mkdir -p ${backdir}/${date} echo “开始备份 ${mysql_dbname1} …” /usr/bin/mysqldump -u $mysql_user -p$mysql_passwd $mysql_dbname1 > ${backdir}/${date}/${mysql_dbname1}.sql sleep 1 if [ $? -eq 0 ];then echo “${mysql_dbname1} backup Successful!” else echo “${mysql_dbname1} backup failed!” exit 1 fi echo “开始备份 ${mysql_dbname2} …” /usr/bin/mysqldump -u $mysql_user -p$mysql_passwd $mysql_dbname2 > ${backdir}/${date}/${mysql_dbname2}.sql sleep 1 if [ $? -eq 0 ];then echo “${mysql_dbname2} backup Successful!” else echo “${mysql_dbname2} backup failed!” exit 1 fi fi return $? } backup() { mysqldump if [ $? -eq 0 ];then echo “${mysql_dbname1} and ${mysql_dbname2} 备份成功!” fi } backup PYTHON #写入crontab,每日00:01进行自动备份。 [root@xusj ~]# cat /etc/crton cat: /etc/crton: No such file or directory [root@iZ287cdnylrZ ~]# cat /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 00 01 * * * * root /bin/bash /backup/backup.sh
本文出自 “少犟” 博客,请务必保留此出处http://xushaojie.blog.51cto.com/6205370/1783609
标签:mysql discuz wordpress already
原文地址:http://xushaojie.blog.51cto.com/6205370/1783609