今天上班只有一台linux系统,就学着在linux上写了个脚本,没啥技术含量
省得每天敲代码备份
没有设置自动备份时间,这里可以参照
http://www.th7.cn/db/mysql/201305/30285.shtml
#!/bin/sh #powered by kangyx echo "get ready,starting backup now !" DUMP=/usr/bin/mysqldump #mysqldump备份程序执行路径 DATE=`date +%Y_%m_%d` #获取当前系统时间 OUT_DIR=/mysql_backup/daily/${DATE} #备份文件存放路径 LINUX_USER=root #系统用户名 DB_NAME=susliks_test #要备份的数据库名字 DB_NAME2=koyoo_test DB_USER=root #数据库用户名 DB_PASS= #数据库密码 mkdir -p "$OUT_DIR" # 创建目录 echo "creating backup file directory "${OUT_DIR}" is ok!" echo "susliks_test first!" cd $OUT_DIR #进入备份存放目录 DB_NAME=susliks_test DB_NAME2=koyoo_test OUT_SQL="${DB_NAME}_${DATE}.sql" #备份数据库的文件名 OUT_SQL2="${DB_NAME2}_${DATE}.sql" $DUMP -u$DB_USER -p$DB_PASS $DB_NAME> $OUT_SQL #备份 susliks_test echo "the backup of suslikes_test_${DATE} is finished" echo "starting koyoo_test now ^_^!" $DUMP -u$DB_USER -p$DB_PASS $DB_NAME2> $OUT_SQL2 #备份 susliks_test echo "the backup of koyoo_test_${DATE} is finished " echo "Have a good day! bye ^_^!"