Get the App
SLTechnology News&Howtos  ›  Database  › 

How to back up and restore mysqldump bulk data script

Shulou Source: shulou.com Published: 2022-06-01 17:41:18 11月13日 Update

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.

Tags: Data scripts backups files interests databases articles more sections text articles industries information parts Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn OPPO Reno NVidia Apple MariaDB