自动备份mysql数据库脚本
#!/bin/sh
# NCONF database backup
# Script by Chen
# add (and adapt) the following line to the corresponding user's crontab:
# 50 23 * * * /usr/local/nconf/ADD-ONS/backup_db.sh
# MYSQL connection parameters (see config/mysql.php)
DBHOST=localhost
DBPORT=3306
DBNAME=test
DBUSER=user
DBPASS=pass
# Other variables
DESTINATION=/usr/local/nconf/BACKUP/db
DATE=`date +%Y%m%d%H%M%S`
KEEPDAY=30
# run backup
mysqldump --host=$DBHOST --port=$DBPORT -u $DBUSER --password=$DBPASS --single-transaction $DBNAME | gzip > $DESTINATION/$DBNAME-$DATE.sql.gz
# delete old backups
find $DESTINATION/ -type f -name "$DBNAME-*.sql.gz" -mtime +$KEEPDAY -exec rm {} \;
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。