In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
/ # # mysql automatic backup script
/ # # write a script for shell automatic backup of mysql database to back up data at 12:00 and 24:00 every day
/ # #
/ # #
/ #! / bin/bash
/ #
/ # DATE: 2019-10-25 #
/ # AUTHOR: zhangy_j #
/ # FUNC: determine the specified database name, and exit the program if not specified #
/ # backup the specified database according to the current test test database #
/ # # this script can be run alone or can be called automatically at 11:00 and 23:00 every day
/ #
/ #-|-- #
/ #
/ # fetching database password files
/ #. / sbin/yujun/.pswd > / dev/null 2 > & 1
/ # export BAK=/databak > / dev/null 2 > & 1
/ # if [!-d $BAK]; then
/ # mkdir-p $BAK > / dev/null
/ # fi
/ # chmod 755-R $BAK
/ # DATAFILE=$ {BAK} / datafile.db
/ # DATA_DIR=$ {BAK}
/ # BAK_DIR=$ {BAK} / bak
/ # BAK_DT=date +% Y%m%d
/ # BAK_LOG=$ {BAK_DIR} / databak$ {BAK_DT} _ log
/ # ERR_LOG=$ {BAK_DIR} / databak$ {BAK_DT} _ errlog
/ # FILE_DT=date +% H
/ # DB_USER='root'
/ # # Backup database host
/ # DB_HOST= "192.168.5.207"
/ # Dempster 1
/ # if [[$1 = ='--help' | | $1 = ='- h']]
/ # then
/ # echo "Usage: $0 database name"
/ # echo "eg:db_bak 11111"
/ # exit
/ # fi
/ # if [x "$1"! = x]; then
/ # echo "- [date" +% Y/%m/%d% H:%M:%S "] start backing up $U database -"
/ # mysqldump-opt-single-transaction-max_allowed_packet=1G-routines-E-master-data=2-ignore-table=gp-data-center.gp_data_send_log-u$DB_USER-p$pass\
/ #-h$DB_HOST ${D} > ${PWD} / ${D} .sql
/ # echo "backup file directory [$PWD]"
/ # ls-lrt $PWD/.sql
/ # echo "- [date" +% Y/%m/%d% H:%M:%S "] backup completed $U database -"
/ # else
/ # Database backup user
/ # DB_USER='root'
/ # # Create backup directory
/ # if [!-d ${BAK_DIR} / ${BAK_DT} / ${FILE_DT}]; then
/ # mkdir-p ${BAK_DIR} / ${BAK_DT} / ${FILE_DT} > / dev/null
/ # fi
/ # if [!-f ${DATAFILE}]
/ # then
/ # echo "$DATAFILE file does not exist!"
/ # echo "Please enter all the database names to be backed up in $DATAFILE!"
/ # exit
/ # fi
/ # print_log () {
/ # MYDATE=date + "Y-%m-%d H:%M:%S"
/ # case ${2} in
/ # 1)
/ # printf "%-40s%s\ n"$1" $3 $4 $5 $6 $7 $8 ${9} "
/ # printf "%-40s%s\ n" $1 "$3 $4 $5 $6 $7 $8 ${9}" > ${BAK_LOG}
/ #
/ #)
/ # echo "input error" > > ${BAK_LOG}
/ #
/ # esac
/ #}
/ # cd ${BAK_DIR} | | exit
/ # for i in cat $DATA_DIR/datafile.db
/ # do
/ # print_log "The database to be backed up is named: $I"1"
/ # DB_FILE=$i.sql
/ #
/ # echo "- [date" +% Y/%m/%d% H:%M:%S "] start backing up ${I} database -" > > ${BAK_LOG}
/ # mysqldump-opt-single-transaction-max_allowed_packet=1G-routines-E-master-data=2-ignore-table=gp-data-center.gp_data_send_log-u$DB_USER\
/ #-p$pass-h$DB_HOST ${I} > ${BAK_DIR} / ${BAK_DT} / ${FILE_DT} / ${DB_FILE}
/ # echo "- [date" +% Y/%m/%d% H:%M:%S "] backup completes ${I} database, backup file ${DB_FILE} -" > > ${BAK_LOG}
/ # sleep 5
/ # F1 ${BAK_DIR} / ${BAK_DT} / ${FILE_DT}
/ # grep'@%'$F1/*.sql | grep-v root | uniq > $F1/aa.txt/#cat $F1/aa.txt | awk-F''{print $1J $2}'| awk-F':'{print $1J NF}'| awk'{print $1}'| uniq | grep-v ^ $| xargs > $F1/a1.txt 2 > / dev/null
/ # cat $F1/aa.txt | awk-F''{print $1Magna $2}'| awk-F':'{print $1pm'NF}'| awk'{print $NF}'| uniq | grep-v ^ $| xargs > $F1/a2.txt 2 > / dev/null/#/#for I incat $F1/a2.txt/#do/#for j incat $F1/a1.txt/#do/#sed-I s/\ ${I} `\ @`% `/ g ${j} > / dev/null 2 > & 1
/ # sleep 1
/ # done
/ # done
/ # rm-f $F1/aa.txt
/ # rm-f $F1/a1.txt
/ # rm-f $F1/a2.txt
/ # sleep 2
/ # sed-I s / `GP-eeds- cms`\ @ `\%` / `root`\ @ `\%` / g eeds-cms.sql > / dev/null 2 > & 1
/ # sed-I s/ `gcy-Base`\ @ `\%` / `root`\ @ `\%` / g gpbl-parb.sql > / dev/null 2 > & 1
/ # sed-I s / `GP-gcy- gpmall`\ @ `\%` / `root`\ @ `\%` / g gp-gpmall.sql > / dev/null 2 > & 1
/ # sed-I s/ `gcy-gpmanage`\ @ `\%` / `root`\ @ `\%` / g gp-manage.sql > / dev/null 2 > & 1
/ # done
/ # fi
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.