您好,登錄后才能下訂單哦!
自動備份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進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。