Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to back up and restore mysqldump bulk data script

2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

I don't know if you know anything about how to back up and restore bulk data scripts like mysqldump. Today, I'm here to tell you a little bit about it. If you are interested, let's take a look at the body. I believe you will gain something after reading the mysqldump bulk data script how to backup and restore mysqldump bulk data script.

The bulk backup script for mysqldump is as follows:

#! / bin/bashDATE= `date "+% Y-%m-%d-%H%M%S" `PORT=3306DB_NAME= `/ usr/local/mysql/bin/mysql-uroot-proot-h20.10.9.111-P3306-s-e "show databases" | grep-v "Database" `for db_name in $DB_NAMEdo / usr/local/mysql/bin/mysqldump-uroot-proot-h20.10.9.111-P3306-- flush-logs-- default-character-set=utf8-- single -transaction-- master-data=2 $db_name > / home/db_backtmp/$db_name-$DATE.sqldonecd / home/db_backtmptar czvf $DATE-$PORT.tar.gz * .sqlrm-rf * .sqlexit 0

Put the list of database names in a file

# cat 00db.txtinformation_schemadb_app_cmsdb_eopdb_leader_cmsdb_leader_comment

The sql data from mysqldump is put into a file.

# cat 00dbsql.txtsql.txtqt1 root root 970701283 May 16 03:39 information_schema-2017-05-16-033001.sqlMurray rwMotMoMoRMY-1 root root 32156 May 16 03:39 db_app_cms-2017-05-16-033001.sqlMuyr Meikai-1 root root 169522095206 May 16 05:50 db_eop-2017-05-16-033001.sqlMur RWMuy RW Mutual-1 root root 99699 May 16 05:50 db_leader_cms-2017-05-16-033001.sqlmurr RWMULI-1 root root 256290013 May 16 05:51 db_leader_comment-2017-05-16-033001.sql

Batch build library and import data script

# cat 00createdb.shemaking binbinash for I in `cat 00db.txt` do for j in `cat / data/backup/00dbsql.txt | awk-F'{print $9} '`do if [[$j = = * "$I"]; then mysql-uroot-proot-S / data/mysql_data/sock/my3306.sock-e "create database $I" "mysql-uroot-proot-S / data/mysql_data/sock/my3306.sock $I < $j echo $i fi done done

Execute script

# nohup 00createdb.sh &

After reading mysqldump bulk data script how to backup and restore this article, what do you think? If you want to know more about it, you can continue to follow our industry information section.

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.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report