MySQL备份数据库并压缩脚本

cat backup_linuxmysql_db-rsc_akcms.sh

#!/bin/bash
#Set the backup filename
DATA=`date +%Y%m%d`
FILENAME="linuxmysql_db_bak_$DATA.sql"
BACKUPDIR="/backup/linuxmysql_db_backup/"
#Database parameter
DBUSER="root"
DBPWD="ruanganlove999"
DBNAME="rsc_akcms"
HOST="localhost"
#Change to the root directory
cd /
#GZIP tool for compression
#The -f parameter will make sure that gzip will overwrite existing files
GZIP="/bin/gzip -f"
#execute the database dump
mysqldump --host=$HOST --user=$DBUSER --password=$DBPWD --add-drop-table --database $DBNAME >$BACKUPDIR$FILENAME
$GZIP $BACKUPDIR$FILENAME

#Delete old backup older than 1 week
find /backup/linuxmysql_db_backup/*.sql.gz -mtime +7 -exec rm {} \;



分割线
感谢打赏
江西数库信息技术有限公司
YWSOS.COM 平台代运维解决方案
 评论
 发表评论
姓   名:

Powered by AKCMS