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 incrementally back up mysql using the binary log shell script

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

The following mainly brings you how to incrementally back up mysql using the binary log shell script. I hope this content can bring you practical use, which is also the main purpose of my article on how to incrementally back up mysql using the binary log shell script. All right, don't talk too much nonsense, let's just read the following.

#! / bin/bash# Date:2017-1 "Description:backup mysql binary logs# Version:0.1db_user=" root "myisam_db=" mysql "db_passwd=" 123456 "host=" localhost "export PATH=" / usr/local/mysql/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin "backup_dir=" / opt/backup/mysql/bin "log_file=" / opt/backup/mysql/bin/bin _ log_file.log "bin_index=" / mydata/data/mysql-bin.index "data_dir=" / mydata/data "mysql=" $(which mysql) "$mysql- u$db_user-h$host-p$db_passwd-e" flush logs "num=$ (awk 'END {print NR}' $bin_index) counter=0start_time=$ (date +"% F% H:%M:%S ") [!-d $backup_dir] & & mkdir-p $backup_dir [!-f $log_file] & & touch $log_fileecho "Starting backup mysql binary logs at $start_time" > > $log_filefor file in `cat $bin_ index`do base= `basename $file`counter=$ (expr $counter + 1) if [$counter-eq $num] Then echo "Skip $base" > > $log_file else if [!-f $backup_dir/$base]; then cp-a $data_dir/$base $backup_dir 2 > > $log_file if [$?-eq 0] Then echo "Backup $base successfully" > > $log_file else echo "Backup $base failed" > > $log_fileecho "Backup $base to $backup_dir failed" | mail-s "MySQL binary logs backup failed" root@localhost fi fi fidonestop_time=$ (date + "% F% H:%M:%S") echo "End backup mysql binary logs at $stop_time" > > $log_fileecho "> > $log_fileexit 0

Do you find it very helpful to use the binary log shell script to back up mysql incrementally? If you need to know more, please continue to follow our industry information. I'm sure you'll like it.

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