自動(dòng)備份MySQL數(shù)據(jù)庫腳本
讓客戶滿意是我們工作的目標(biāo),不斷超越客戶的期望值來自于我們對(duì)這個(gè)行業(yè)的熱愛。我們立志把好的技術(shù)通過有效、簡單的方式提供給客戶,將通過不懈努力成為客戶在信息化領(lǐng)域值得信任、有價(jià)值的長期合作伙伴,公司提供的服務(wù)項(xiàng)目有:空間域名、網(wǎng)頁空間、營銷軟件、網(wǎng)站建設(shè)、易門網(wǎng)站維護(hù)、網(wǎng)站推廣。
#!/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 {} \;